I've been reading how the newer jQuery features Deferred
/ promise
/ when
/ then
can be used to simplify acting on multiple asynchronous events such as AJAX queries.
But all of the examples I've been reading talk about a set number of queries that are known in advance.
$.when($.ajax("/page1.php"), $.ajax("/page2.php")).then(myFunc, myFailure);
(Borrowed from Coding Freak's answer here)
What about when you don't know them in advance, such as calling the same paged web API in a loop with different parameters, such as some features of the MediaWiki and StackExchange APIs have - is there any way to make use of these newer jQuery features in this case or do we have to go back to the old way?