Skip to content

Instantly share code, notes, and snippets.

@rickhernandezio
Created May 19, 2018 16:08
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 rickhernandezio/8a5c188e8b8e60b28b6313d77abe5bd7 to your computer and use it in GitHub Desktop.
Save rickhernandezio/8a5c188e8b8e60b28b6313d77abe5bd7 to your computer and use it in GitHub Desktop.
Process a list of sequential ajax requests using jQuery
var requests = [];
for (var key in data) { /* Create the list of requests */
if (data[key].value === 'file') {
requests.push(GetAjaxCall(data[key].uid));
}
}
$.when.apply($, requests).then(function() {
/* All done... */
});
function GetAjaxCall(uid) {
return $.ajax({ /* Compose your ajax request */
type: 'DELETE',
url: '/some/location',
data: {
uid: uid
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment