Skip to content

Instantly share code, notes, and snippets.

@sergio-fry
Created October 19, 2012 09:49
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sergio-fry/3917217 to your computer and use it in GitHub Desktop.
Save sergio-fry/3917217 to your computer and use it in GitHub Desktop.
Jquery Deferred Parallel Example
stuff1 = function(deferred) {
setTimeout(function() {
console.log("Stuff #1 is done!");
deferred.resolve();
}, 1000);
};
stuff2 = function(deferred) {
setTimeout(function() {
console.log("Stuff #2 is done!");
deferred.resolve();
}, 500);
};
stuff3 = function(deferred) {
setTimeout(function() {
console.log("Stuff #3 is done!");
deferred.resolve();
}, 500);
};
$.when($.Deferred(stuff1), $.Deferred(stuff2), $.Deferred(stuff3)).then(function() {
console.log("done!");
});​
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment