Created
June 28, 2017 09:31
-
-
Save jbardon/c28b6bcbf2ef473f3fed75605831e4d8 to your computer and use it in GitHub Desktop.
Jquery promises examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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