Why Ext.Ajax.request can't pass by value

Imitate the dynamic generation of grid, of which the main a section of code
	var json_f;  
        Ext.Ajax.request({//The store object needs to develop the fields attribute in the creation, so use ajax first get the column names from the background   
            url : 'rt.asp', //Read the data returned from the action response, also can get data from other places    
            method : 'POST',  
            async : false,  
            success : function(response) {  
                //Returns the results are converted to JSON objects, note that the extjs4 function in decode has become: Ext.JSON.decode   
  
                s = response.responseText;  
            json_f = Ext.util.JSON.decode(s); //For backstage pass JSON 
  				
            }  
        });


The following is the structure of store
	 var humresStore = new Ext.data.Store({  
           fields : json_f.fields,//According to the above AJAX is obtained from the dynamic background action   
           proxy : {
				type : 'ajax',  
                url : 'rt.asp',//Data acquisition URL   
                method : 'POST',  
                reader : {  
                    type : 'json',  
                    root : 'data',  
                    totalProperty : 'totalRecord'//JSON data, said the total number of paging data   
                }  
            }
        });

Only above the Ext.Ajax.request, debugging through, json_f can be achieved,
Construction of store this step dead live not to, use IE debugging, json_f is not defined, so json_f.fields is empty

Debugging N times do not know where the problem lies in, please explain

Started by Wythe at November 08, 2016 - 4:49 AM

What version of ext, if ext4 doesn't support async synchronization requests.

Structure of the store code in the callback
  var json_f;  
        Ext.Ajax.request({//The store object needs to develop the fields attribute in the creation, so use ajax first get the column names from the background   
            url : 'rt.asp', //Read the data returned from the action response, also can get data from other places    
            method : 'POST',  
            async : false,  
            success : function(response) {  
                //Returns the results are converted to JSON objects, note that the extjs4 function in decode has become: Ext.JSON.decode   
   
                s = response.responseText;  
            json_f = Ext.util.JSON.decode(s); //For backstage pass JSON 
                   

var humresStore = new Ext.data.Store({  
           fields : json_f.fields,//According to the above AJAX is obtained from the dynamic background action   
           proxy : {
                type : 'ajax',  
                url : 'rt.asp',//Data acquisition URL   
                method : 'POST',  
                reader : {  
                    type : 'json',  
                    root : 'data',  
                    totalProperty : 'totalRecord'//JSON data, said the total number of paging data   
                }  
            }
        });

            }  
        });

Posted by Victoria at November 16, 2016 - 5:41 AM