Created
May 19, 2018 16:08
-
-
Save rickhernandezio/8a5c188e8b8e60b28b6313d77abe5bd7 to your computer and use it in GitHub Desktop.
Process a list of sequential ajax requests using jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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