Skip to content

Instantly share code, notes, and snippets.

@mkempe
Created February 18, 2012 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkempe/1861348 to your computer and use it in GitHub Desktop.
Save mkempe/1861348 to your computer and use it in GitHub Desktop.
Multiple Ajax request with jQuery
var queue = [];
$.each(foobars, function(i, foobar) { // Built up queue
queue.push($.getJSON(
'http://foobar.com/foo.js', // URL
{ foo: foobar.bar }, // Params
function(data) { // Callback
# ...
));
});
$.when.apply($, queue).done(function() {
console.log('Woot!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment