Skip to content

Instantly share code, notes, and snippets.

@jincod
Created March 23, 2016 12:49
Show Gist options
  • Save jincod/8acaf5bb701134de9dc8 to your computer and use it in GitHub Desktop.
Save jincod/8acaf5bb701134de9dc8 to your computer and use it in GitHub Desktop.
var urls = [];
var tasks = urls.map(function(url) {
return $.getJSON(url);
});
var lastPromise = urls.reduce(function(promise, url) {
return promise.then(function() {
return $.ajax(url);
});
}, Promise.resolve());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment