Skip to content

Instantly share code, notes, and snippets.

@sters
Last active January 1, 2016 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sters/8119832 to your computer and use it in GitHub Desktop.
Save sters/8119832 to your computer and use it in GitHub Desktop.
jqDeferred
$.when(naga_______i_shori())
.done(function() {
console.log("OK!");
}).fail(function() {
console.log("fail...");
}).always(function() {
console.log("way");
});
function naga_______i_shori(){
var d = new $.Deferred();
setTimeout(function(){
Math.random() > 0.5 ?
d.resolve() : d.reject();
}, 2000);
return d.promise();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment