Results 1 to 3 of 3

Thread: alert data outside ajax

  1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    5
    Answers
    1
    Vote Rating
    0
      0  

    Default Answered: alert data outside ajax

    Hi, (sorry for my english...)

    i have a problem... i hae a function who i get an "ajax" data.... this data i write in an array!!
    <<<<this works>>>>

    but how i can "alert" this array outside from the "ajax-function"
    ????

    - any ideas -

    PHP Code:
                            Ext.define('SaherdData', { singletontrue,
                                
    fields: []
                            });                     
                        
                            
    Ext.Ajax.request({
                                
    url'benchmark/ajax_getStandorte.php',
                                
    success: function (resultrequest) { 
                                    
                                    var 
    jsonData Ext.decode(result.responseText);
                                    for (
    data in jsonData) {
                                        
    SaherdData.fields.push(jsonData[data].standort);
                                    }

                                    
    // HERE IT WORKS!!!!
                                    //alert(SaherdData.fields);
        
                                
    }
                            });    
                            
                            
    // AND HERE NOT!!!!
                            
    alert(SaherdData.fields); 

  2. i will create a dynamic line chart! ...at first i will initialize the "fields" from json.Store!!

    PHP Code:
    var store Ext.create('Ext.data.JsonStore', {
       
    fieldsmyfields,
       
    datamydata
    }); 
    "myfields" and "mydata" i will GET with ajax!

    what is the way to do this? - or are there a better way??

  3. #2
    Sencha User Izhaki's Avatar
    Join Date
    Apr 2009
    Location
    London
    Posts
    118
    Answers
    7
    Vote Rating
    14
      0  

    Default

    The ajax request is asynchronies - the success function is called via a callback once the server respond, and not inline with the main execution code.

    What exactly you are trying to do? Because if it is just a matter of having a more organised code that you can provide success with a local object method.

  4. #3
    Sencha User
    Join Date
    Jun 2012
    Posts
    5
    Answers
    1
    Vote Rating
    0
      0  

    Default

    i will create a dynamic line chart! ...at first i will initialize the "fields" from json.Store!!

    PHP Code:
    var store Ext.create('Ext.data.JsonStore', {
       
    fieldsmyfields,
       
    datamydata
    }); 
    "myfields" and "mydata" i will GET with ajax!

    what is the way to do this? - or are there a better way??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •