I need to make a number of ajax calls(the exact number is variable) and wait for them all to complete. My current code is as follows:
ajaxRequests = new Array();
ajaxRequests.push(function(){
return jQuery.post(url: "someUrl",
dataType: "json",
data: yourJsonData
});
jQuery.when.apply(jQuery, ajaxRequests).done(function(){
alert("ajax requests done");
});
Unfortunatly the above code is not waiting for the ajax request to finish. Any help would be apprecited.