Skip to content

Instantly share code, notes, and snippets.

@gravesm
gravesm / gist:5112054
Last active December 14, 2015 15:59
Control a queue of jQuery AJAX requests from within an XHR callback, rather than just from the return promise object. For example, only run the next request if some aspect of the data from the current request is true.
var Queue = function() {
var reqs = [],
dfds = [];
function run() {
var next = reqs.shift();
if (next) {
$.ajax(next);
}
}