Skip to content

Instantly share code, notes, and snippets.

@panphora
Last active December 22, 2015 07:29
Show Gist options
  • Save panphora/6437938 to your computer and use it in GitHub Desktop.
Save panphora/6437938 to your computer and use it in GitHub Desktop.
simple jquery deferred example
var bringMeToast = function () {
var d = new $.Deferred();
setTimeout(function () {
d.resolve()
}, 2000);
return d;
};
var bringMeASwartwouter = function () {
var d = new $.Deferred();
setTimeout(function () {
d.resolve()
}, 5000);
return d;
};
$.when(bringMeToast(), bringMeASwartwouter()).then(function () {
console.log('mm delicious swartwouter on toast'); // get this after 5 seconds
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment