Skip to content

Commit 8810ad4

Browse files
committed
Fix first code block. Fixes #50, #74, #82, #116
1 parent aa8ac67 commit 8810ad4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

entries/jQuery.when.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
<desc>One or more Deferred objects, or plain JavaScript objects.</desc>
88
</argument>
99
</signature>
10-
<desc><![CDATA[Provides a way to execute callback functions based on one or more objects, usually <a href="/category/deferred-object/">Deferred</a> objects that represent asynchronous events.]]></desc>
10+
<desc>Provides a way to execute callback functions based on one or more objects, usually <a href="/category/deferred-object/">Deferred</a> objects that represent asynchronous events.</desc>
1111
<longdesc>
12-
<p>If a single Deferred is passed to <code>jQuery.when</code>, its Promise object (a subset of the Deferred methods) is returned by the method. Additional methods of the Promise object can be called to attach callbacks, such as <a href="/deferred.then"><code>deferred.then</code></a>. When the Deferred is resolved or rejected, usually by the code that created the Deferred originally, the appropriate callbacks will be called. For example, the jqXHR object returned by <code>jQuery.ajax</code> is a Deferred and can be used this way:</p>
13-
<pre><code>$.when( $.ajax("test.aspx") ).then(function(ajaxArgs){
14-
alert(ajaxArgs[1]); /* ajaxArgs is [ "success", statusText, jqXHR ] */
12+
<p>If a single Deferred is passed to <code>jQuery.when</code>, its Promise object (a subset of the Deferred methods) is returned by the method. Additional methods of the Promise object can be called to attach callbacks, such as <a href="/deferred.then"><code>deferred.then</code></a>. When the Deferred is resolved or rejected, usually by the code that created the Deferred originally, the appropriate callbacks will be called. For example, the jqXHR object returned by <code>jQuery.ajax()</code> is a Promise and can be used this way:</p>
13+
<pre><code>$.when( $.ajax("test.aspx") ).then(function(data, textStatus, jqXHR){
14+
alert( jqXHR.status ); // alerts 200
1515
});</code></pre>
1616
<p>If a single argument is passed to <code>jQuery.when</code> and it is not a Deferred, it will be treated as a resolved Deferred and any doneCallbacks attached will be executed immediately. The doneCallbacks are passed the original argument. In this case any failCallbacks you might set are never called since the Deferred is never rejected. For example:</p>
1717
<pre><code>$.when( { testing: 123 } ).done(
18-
function(x){ alert(x.testing); } /* alerts "123" */
18+
function(x) { alert(x.testing); } /* alerts "123" */
1919
);</code></pre>
2020
<p>In the case where multiple Deferred objects are passed to <code>jQuery.when</code>, the method returns the Promise from a new "master" Deferred object that tracks the aggregate state of all the Deferreds it has been passed. The method will resolve its master Deferred as soon as all the Deferreds resolve, or reject the master Deferred as soon as one of the Deferreds is rejected. If the master Deferred is resolved, it is passed the resolved values of all the Deferreds that were passed to <code>jQuery.when</code>. For example, when the Deferreds are <code>jQuery.ajax()</code> requests, the arguments will be the jqXHR objects for the requests, in the order they were given in the argument list.</p>
2121
<p>In the multiple-Deferreds case where one of the Deferreds is rejected, <code>jQuery.when</code> immediately fires the failCallbacks for its master Deferred. Note that some of the Deferreds may still be unresolved at that point. If you need to perform additional processing for this case, such as canceling any unfinished ajax requests, you can keep references to the underlying jqXHR objects in a closure and inspect/cancel them in the failCallback.</p>
@@ -41,4 +41,4 @@
4141
<category slug="core"/>
4242
<category slug="deferred-object"/>
4343
<category slug="version/1.5"/>
44-
</entry>
44+
</entry>

0 commit comments

Comments
 (0)