Skip to content

Instantly share code, notes, and snippets.

@thisgeek
Created May 3, 2012 17:04
Show Gist options
  • Save thisgeek/2587277 to your computer and use it in GitHub Desktop.
Save thisgeek/2587277 to your computer and use it in GitHub Desktop.
$.ajax({
success: function (data) {
console.log("Yay! You gots datums!");
},
error: function (jqXHR, status, error) {
console.log("Error? Handled it.");
},
complete: function () {
console.log("It's over.");
}
});
$.ajax().done(function (data) {
console.log("Yay! You gots datums!");
}).fail(function (jqXHR, status, error) {
console.log("Error? Handled it.");
}).always(function () {
console.log("It's over.");
});
doAThing().then(function () {
console.log(
"Do another thing" +
"after the previous thing is done"
);
});
var doAThing = function () {
var deferred = jQuery.Deferred();
deferred.fail(function () {
throw("Aw, snap.");
});
return deferred;
};
var doAThing = function () {
return jQuery.Deferred().fail(function () {
throw("Aw, snap.");
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment