Skip to content

Instantly share code, notes, and snippets.

@jbardon
Created June 28, 2017 09:31
Show Gist options
  • Save jbardon/c28b6bcbf2ef473f3fed75605831e4d8 to your computer and use it in GitHub Desktop.
Save jbardon/c28b6bcbf2ef473f3fed75605831e4d8 to your computer and use it in GitHub Desktop.
Jquery promises examples
// Single async all
$.when(myFunction)
.then(followingFunction);
// Multiple async call
var promises = [ myFunction(), myFunction() ]
$.when(myFunction)
.apply($, promises)
.then(followingFunction);
// Example async function
function myFunction(){
var defer = $.Deferred();
asyncFunction(function callback(){
defer.resolve();
});
return defer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment