Using jQuery 1.5 pending objects:
Accumulate an array of JQXHR objects returned by $.getJSON()
var jxhr = urls.map(function(url) { return $.getJSON(url, function(json) { result += json.field1; }) });
and only $.when they are all .done() :
$.when.apply($, jxhr).done(function() { alert(result); });
NB: this will accumulate result in the order in which the AJAX calls end, and not in the order in which they are made.
source share