jQuery deferred.fail()Method
Example
Call deferred.fail() when the Deferred object is rejected
$(function () {
$.get("test.php")
.done(function(){ alert("$.get success!"); })
.fail(function(){ alert("$.get failed!"); });
})
Try it »
Definition and Usage
The deferred.fail() function calls the added handlers when the Deferred object is rejected.
Tip:This method accepts one or more parameters. deferred.fail() returns a Deferred object, which can be chained to other deferred object methods, including additional .fail() methods. When the Deferred object is rejected, the callback functions execute in the order they were added, and can be passed as parameters to methods such as: deferred.resolve() or deferred.rejectWith().
Syntax
deferred.fail( failCallbacks [, failCallbacks ] )
| Parameter | Description |
|---|---|
| failCallbacks | Function type - A function or array of functions, called when the Deferred object is rejected |
| failCallbacks | Optional. Function type - A function or array of functions, called when the Deferred object is rejected |
Other Extensions
jQuery Miscellaneous Methods