Easy Tutorial
❮ Misc Deferred Isresolved Sel Animated ❯

jQuery deferred.fail() Method

jQuery Miscellaneous Methods

Example

The deferred.fail() method is called when the Deferred object is rejected.

$(function () { 
    $.get("test.php")
        .done(function(){ alert("$.get succeeded!"); })
        .fail(function(){ alert("$.get failed!"); });
})

Definition and Usage

The deferred.fail() function adds handlers to be called when the Deferred object is rejected. Note: This method accepts one or more arguments. deferred.fail() returns a Deferred object, which can be chained with other Deferred methods, including additional .fail() methods. When the Deferred object is rejected, the callback functions are executed in the order they were added, and can be passed as arguments to methods such as deferred.resolve() or deferred.rejectWith().


Syntax

Parameter Description
failCallbacks Function type. A function or array of functions to be called when the Deferred object is rejected.
failCallbacks Optional. Function type. A function or array of functions to be called when the Deferred object is rejected.

jQuery Miscellaneous Methods

❮ Misc Deferred Isresolved Sel Animated ❯