Category: Deferred Object

The Deferred object, introduced in jQuery 1.5, is a chainable utility object created by calling the jQuery.Deferred() method. It can register multiple callbacks into callback queues, invoke callback queues, and relay the success or failure state of any synchronous or asynchronous function.

The Deferred object is chainable, similar to the way a jQuery object is chainable, but it has its own methods. After creating a Deferred object, you can use any of the methods below by either chaining directly from the object creation or saving the object in a variable and invoking one or more methods on that variable.

deferred.always()
Add handlers to be called when the Deferred object is either resolved or rejected.

deferred.catch()
Add handlers to be called when the Deferred object is rejected.

deferred.done()
Add handlers to be called when the Deferred object is resolved.

deferred.fail()
Add handlers to be called when the Deferred object is rejected.

Also in: Deprecated > Deprecated 1.7 | Removed
deferred.isRejected()
Determine whether a Deferred object has been rejected.

Also in: Deprecated > Deprecated 1.7 | Removed
deferred.isResolved()
Determine whether a Deferred object has been resolved.

deferred.notify()
Call the progressCallbacks on a Deferred object with the given args.

deferred.notifyWith()
Call the progressCallbacks on a Deferred object with the given context and args.

Also in: Deprecated > Deprecated 1.8
deferred.pipe()
Utility method to filter and/or chain Deferreds.

deferred.progress()
Add handlers to be called when the Deferred object generates progress notifications.

deferred.promise()
Return a Deferred’s Promise object.

deferred.reject()
Reject a Deferred object and call any failCallbacks with the given args.

deferred.rejectWith()
Reject a Deferred object and call any failCallbacks with the given context and args.

deferred.resolve()
Resolve a Deferred object and call any doneCallbacks with the given args.

deferred.resolveWith()
Resolve a Deferred object and call any doneCallbacks with the given context and args.

deferred.state()
Determine the current state of a Deferred object.

deferred.then()
Add handlers to be called when the Deferred object is resolved, rejected, or still in progress.

jQuery.Deferred()
A factory function that returns a chainable utility object with methods to register multiple callbacks into callback queues, invoke callback queues, and relay the success or failure state of any synchronous or asynchronous function.

Also in: Core
jQuery.when()
Provides a way to execute callback functions based on zero or more Thenable objects, usually Deferred objects that represent asynchronous events.

.promise()
Return a Promise object to observe when all actions of a certain type bound to the collection, queued or not, have finished.

发布了73 篇原创文章 · 获赞 189 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/blog_programb/article/details/105570179
今日推荐