1. #1
    Ext User
    Join Date
    Mar 2008
    Posts
    26
    Vote Rating
    0
    genix is on a distinguished road

      0  

    Default Ajax request...

    Ajax request...


    Hello,

    i have the following code:
    Code:
    MD.ServerStatus = function(){
    var status = '';
    Ext.Ajax.request({
        url: '../server/get-status.php',
        success: function(xhr){
            status = Ext.decode(xhr.responseText);
        }
    });
    
    return {
        activeTab: 0,
        deferredRender : false,
        border: false,
    
        items: [{
            title: 'SomeTitle',
            html:   '<b>' + status.online + '</b>'
           }]
    }};
    My Problem here is, that status.online is always undefined. The requestdata ist alright and if I do inside of 'request.success' alert(status.online) it works.

    Does anyone know how to do this?

    greetings
    genix

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    The request is async - you need to build the object you're returning in a callback after the request completes.

  3. #3
    Ext User
    Join Date
    Mar 2008
    Posts
    26
    Vote Rating
    0
    genix is on a distinguished road

      0  

    Default


    Hi,

    could you please give me an example? I just don't know how

    greetings
    genix

  4. #4
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    Quote Originally Posted by genix View Post
    Hi,

    could you please give me an example? I just don't know how

    greetings
    genix
    You do know how. You already said it. That "success" method is your callback.

  5. #5
    Ext User
    Join Date
    Mar 2008
    Posts
    26
    Vote Rating
    0
    genix is on a distinguished road

      0  

    Default


    Ok thanks. Not quite what I wanted, but still found a way.

    That's how i did it:

    Code:
    function setValues(id, xhr, values){
            for(i=0;i<values.length;i++){
                Ext.get(id + '-' + values[i] + '-' + windowid).dom.innerHTML = eval('xhr.'+values[i]);
            }
    };
    
    Ext.Ajax.request({
                url: '../server/get-status.php',
                waitMsgTarget: true,
                success: function(xhr){
                    var status = Ext.decode(xhr.responseText);
                    setValues('dlg-status',status,['online','version','recorder','sender','onlinetime','csongs','space']);
                }
    });
    Greetings,
    genix

  6. #6
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    If you continue to program this way you're going to lead yourself to problems. I would suggest that you get a book about OO JavaScript techniques and also do some reading about why you don't use 'eval' in a situation like that. If you're going to be successful with Ext, you're going to have get away from old-school global functions, evals and tightly coupling things together.

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi