Skip to content

Instantly share code, notes, and snippets.

@hubgit
Created February 20, 2014 17:38
Show Gist options
  • Save hubgit/9119234 to your computer and use it in GitHub Desktop.
Save hubgit/9119234 to your computer and use it in GitHub Desktop.
JS Request queue
var queue = [
'https://peerj.com/articles/1.json',
'https://peerj.com/articles/2.json',
'https://peerj.com/articles/3.json',
];
var run = function() {
var xhr = new XMLHttpRequest;
xhr.open('GET', queue.shift());
xhr.responseType = 'json';
xhr.onload = function() {
console.log(xhr.response);
if (queue.length) {
run();
}
}
xhr.send();
}
run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment