jQuery.when () method
Examples
A parameter passed to the $ .when () is accepted, the implementation of the callback function
try it"
Definition and Usage
$ .when () Function provides a way to execute one or more objects of the callback function.
Tip: If you pass an object to a delay jQuery.when, then it will return Promise objects (a subset of the delay method). Other methods can continue to bind the Promise object, for example, defered.then. When the delay object has been accepted (resolved) or rejected (rejected) (usually created by the delay in the initial object code execution), it will call the corresponding callback function.
grammar
参数 | 描述 |
---|---|
deferreds | Deferred类型 一个或多个延迟对象,或者普通的JavaScript对象 |
More examples
If you do not pass any parameters, jQuery.when () returns a resolved (accepted) promise object's state.
Examples
Do not pass any parameters, perform the callback function
try it"
A plurality of delay in the case of the object passed to jQuery.when (), the method returns a new "host" lingering objects when all the objects are delayed acceptance (resolve), the method will not accept its host lingering objects . When there is a delay in which the object is denied (rejected), this method will reject its host lingering objects. When a host object is accepted, doneCallbacks (accept callback) will be executed.
Examples
A plurality of delay incoming objects
try it"
If no value is passed to the delay in receiving the object (resolved) event, then the corresponding doneCallback argument will be undefined. If you pass an object to the delay in receiving (resolved) event as a single value, the corresponding parameters will retain that value. In passing to resolve lingering objects (resolved) into a plurality of event value, the corresponding argument will be an array of these values.
Examples
Incoming number of different types of lingering objects
try it"
In the case of a plurality of delay, if the delay is one of the object is denied (rejected), jQuery.when () call immediately trigger "host" lingering objects failCallbacks callback function.
Examples
Callback function call failCallbacks one of a plurality of delay object denied
try it"