I am writing a google content script and my program needs to make roughly 30 AJAX calls to the server. I am using JQuery's .when function in conjunction with .apply to pass in an array to the .when function. I am also using .done and I want to be able to pass in an array of arguments that will take on the deferred objects from the .when function. Is there any way to do this? This is what I am trying to do.
var callback = function(a) {
console.log("done", a);
};
var requests = [];
var requestArray = [];
for(i = 0; i < liclass.length; i++) {
requests.push($.ajax({
url: liclass[i],
success: function() {;
}
}));
var str = "messageArg" + i
requestArray.push(str)
}
$.when.apply($, requests).done(function(requestArray){
callback(requestArray)});