0

I have following question. With jQuery.when we can execute something when several asynchronous requests is finished. This is some example code (I have taken it from jQuery site):

$.when( $.ajax( "/page1.php" ), $.ajax( "/page2.php" ) ).done(function( a1, a2 ) {
      // other code
});

But I want to dynamically add something to this clause:

$.ajax( "/page1.php" ), $.ajax( "/page2.php" )

For example $.ajax( "/page3.php" ) or remove $.ajax( "/page2.php" ). Is this is possible? I would be very grateful for any comment.

Best regards.

Georgi Naumov
  • 4,030
  • 4
  • 38
  • 55
  • So, you're saying you want to pass a single array to `$.when` instead of each deferred item individually? – Rory McCrossan Oct 31 '13 at 15:18
  • 5
    You can use `$.when.apply()` to pass an array of `deferred`s to `$.when()`. See [this SO question](http://stackoverflow.com/questions/14777031/what-does-when-apply-somearray-do) – Jason P Oct 31 '13 at 15:18

0 Answers0