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 pas
If you look at the examples for $.when, you see that the call back gets passed an argument for each promise. If that promise came from an Ajax call, then each argument is an array of the form [ data, statusText, jqXHR ]
.
So you you just have iterate over the arguments and extract the first element. $.map
makes that very easy:
$.when.apply($, requests)
.then(function() {
return $.map(arguments, function(v) {
return v[0];
});
})
.done(callback);