Easy Tutorial
❮ Jquery Ref Ajax Misc Deferred Rejectwith ❯

jQuery deferred.then() Method

jQuery Miscellaneous Methods

Example

Add the .then method

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

Definition and Usage

The deferred.then() function is called when the Deferred object is resolved, rejected, or still in progress, and adds handlers.

Note: 1. The parameters can be null. Alternatively, use .done(), .fail(), or .progress() to set only one callback type for an unfiltered state or value.


Syntax

Method One

Method Two

Parameter Description
doneFilter Function type, optional. A function called when the Deferred object is resolved.
failFilter Function type, optional. A function called when the Deferred object is rejected.
progressFilter Function type, optional. A function called when the Deferred object generates progress notifications.
Parameter Description
doneCallbacks Function type. A function or array of functions called when the Deferred object is resolved.
failCallbacks Function type. A function or array of functions called when the Deferred object is rejected.
progressCallbacks Function type. A function or array of functions called when the Deferred object generates progress notifications.

More Examples

Filter Resolved Values

Filter Rejected Values

Chain Tasks


jQuery Miscellaneous Methods

❮ Jquery Ref Ajax Misc Deferred Rejectwith ❯