Saturday, March 29, 2014

Use data from success of AJAX on next step

If you are using ajax request for get and post data then you are also know about thier scopes but I would like to tell you one scope which is very userful when you need data from ajax and then you need to use it after ajax.

I meant that we can use data outside of ajax when we get response from AJAX.

so its cool!!!

We can use "async" scope for this purpose.

We can maintain orders by async. Otherwise AJAX will move on next orderand in this example if we not using async:false then we are not able to use jsonData after ajax response.

Here is one example for use this scope so you can also look at it!!!
function findData(id) {     
      var data;  
          url: this.urlRoot + "/" + id + "/endData", 
          async: false,
          dataType: "json",           
                     success: function(jsonData){                
                       data = jsonData;     
             var used_Data = jsonData;      


Post a Comment