Latest web development tutorials

jQuery deferred.then () method

jQuery Misc Methods jQuery Misc Methods

Examples

Add .then method

$ (Function () {$. Get ( "test.php" ). Then ( function () { alert ( "$ .get success");}, function () { alert ( "$ .get failed!");} );})

try it"

Definition and Usage

deferred.then () function when the Deferred (delay) object is solved, rejected or is still in progress, add a call handler.


Note: 1. The parameters can be null. Or use .done () ,. fail () or .progress () Sets the callback only one type of unfiltered state or value.
2. From the beginning of jQuery 1.8, the method returns a new promise, may be deferred by a filter function (delay) and the value of the object's state, to replace the now obsolete deferred.pipe () method.
3. The callback is added in the order they were executed because deferred.then return Promise objects Promise can link other objects, including additional .then () method.


grammar

method one

deferred.then( doneFilter [, failFilter ] [, progressFilter ] )

Method Two

deferred.then( doneCallbacks, failCallbacks [, progressCallbacks ] )

参数 描述
doneFilter Function类型 可选 当Deferred(延迟)对象得到解决时被调用的一个函数。
failFilter Function类型 可选 当Deferred(延迟)对象拒绝时被调用的一个函数。
progressFilter Function类型 可选 当Deferred(延迟)对象生成进度通知时被调用的一个函数。
参数 描述
doneCallbacks Function类型 当Deferred(延迟)对象得到解决时被调用的一个函数或函数数组。
failCallbacks Function类型 当Deferred(延迟)对象拒绝时被调用的一个函数或函数数组。
progressCallbacks Function类型 当Deferred(延迟)对象生成进度通知时被调用的一个函数或函数数组。


Examples

More examples

Filtering Value
Filtering value.

Reject filter value
Reject filter value.

Chain task
Chain task.


jQuery Misc Methods jQuery Misc Methods