jQuery deferred.resolveWith()Method

jQuery 杂项方法jQuery Miscellaneous Methods


Definition and Usage

The deferred.resolveWith() function is used to resolve a Deferred object and call any doneCallbacks callback functions based on the given context and args parameters.


Note:1. Usually only the creator of the deferred object can call this method. You can return a restricted Promise object by calling deferred.promise(), to prevent other code from changing the state of the deferred object or reporting its status.
2. When the deferred object is resolved, any doneCallbacks added via deferred.then or deferred.done will be called. The callback functions execute in the order they were added. The args parameter passed to deferred.resolve() is passed to each callback function. After the deferred object enters the resolved state, any doneCallbacks added will be executed immediately, with the arguments passed to .resolve().


Syntax

deferred.resolveWith( context [, args ] )

Parameters Description
context Object type — Passed to the doneCallbacks callback function as the this object
args Array type — Passes an optional array of arguments to the oneCallbacks callback function


jQuery 杂项方法jQuery Miscellaneous Methods

Other Extensions