Last active
January 1, 2016 08:39
-
-
Save sters/8119832 to your computer and use it in GitHub Desktop.
jqDeferred
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
$.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