Skip to content

Instantly share code, notes, and snippets.

@flackend
Created September 18, 2013 17:43
Show Gist options
  • Save flackend/6612758 to your computer and use it in GitHub Desktop.
Save flackend/6612758 to your computer and use it in GitHub Desktop.
doSomething(elements);
function doSomething(elements, i) {
// For first iteration
if(i === undefined) i = 0;
var element = elements[i];
$.ajax({
url: element.url,
success: function(data) {
// Make HTML changes
element.$el.html(data);
// Make the next AJAX call
doSomething(elements, ++i);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment