It is almost the same with this question: Wait until all jQuery Ajax requests are done?
But my question is imporve:
That I'm doing many ajax requests, and I save them in an array:
var events = [];
for(var i = 0; i < 10; ++i) {
events.push($.ajax({...}));
}
$.when(events).done(function() {
// do something when all requests are done.
});
As the related question tells, the $.when method takes some jqXHR
object in order, but here I want a list of them taken.
And I read the documents in http://api.jquery.com/jQuery.when/#jQuery-when-deferreds, but the method seemed not supporting this case (passing a list of jqXHR
to $.when
function)
How could it be? Plz help.