1

Per this post: https://stackoverflow.com/a/17548609/985704

Using jQuery.when to perform multiple simultaneous ajax requests.

var requests = Array();
requests.push($.get('responsePage.php?data=foo'));
requests.push($.get('responsePage.php?data=bar'));

var defer = $.when.apply($, requests);
defer.done(function(){

    // This is executed only after every ajax request has been completed

    $.each(arguments, function(index, responseData){
        // "responseData" will contain an array of response information for each specific request
    });

});

When all requests are done, can I be sure that the arguments (of the $.each) are in the same order as the requests? Is this documented somewhere?

TylerH
  • 20,799
  • 66
  • 75
  • 101
egret
  • 179
  • 2
  • 8
  • 1
    Yes. "_The arguments passed to the doneCallbacks provide the resolved values for each of the Deferreds, and matches the order the Deferreds were passed to jQuery.when()._" http://api.jquery.com/jQuery.when/ – Jason P Oct 07 '14 at 16:22

1 Answers1

1

Per JasonP: (thank you)

Yes. "The arguments passed to the doneCallbacks provide the resolved values for each of the Deferreds, and matches the order the Deferreds were passed to jQuery.when()." api.jquery.com/jQuery.when

egret
  • 179
  • 2
  • 8