title: javascript wait for several callback finished
body: <p>I have a following javascript program：</p>
  
  <pre><code>                function jQueryFunction(url, callback)
                  { 
                      $.ajax
                              ({
                                  type: "GET",
                                  async: true,
                                  url: url,
                                  dataType: "jsonp",
                                  jsonp: "callback",
                                  jsonpCallback: "tpsHandler",
                                  success: function(json)
                                  {
                                      return callback(json);
                                  }
                              });  
                  }
  
                  var jsonArray = new Array();
                  for(var i = 0; i &lt; 10; i++)
                  {
                      jQueryFunction(url[i], function(json){
                         jsonArray[i] = json;
                      });
                  }
  
                  //process jsonArray
  </code></pre>
  
  <p>However, when I check jsonArray after the for loop, it is null. So my question is that how to store the return value from jQueryFunction to jsonArray in for loop and then process it?</p>
  
  <p>I have tried $.when.apply($,jsonArray).done(function) but still the same, it is null.</p>