Skip to content

Instantly share code, notes, and snippets.

@terrymun
Last active December 28, 2015 20:44
Show Gist options
  • Save terrymun/ca95de155b7cbd892769 to your computer and use it in GitHub Desktop.
Save terrymun/ca95de155b7cbd892769 to your computer and use it in GitHub Desktop.
Better $.ajax() requests — multiple AJAX response evaluation
var a1 = $.ajax({...}),
a2 = $.ajax({...});
$.when(a1, a2).done(function(r1, r2) {
// Each returned resolve has the following structure:
// [data, textStatus, jqXHR]
// e.g. To access returned data, access the array at index 0
console.log(r1[0]);
console.log(r2[0]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment