Skip to content

Commit 7765834

Browse files
committed
jQuery.ajaxTransport: Add object signature to completeCallback
This will be supported since jQuery 4.1.
1 parent 12b1054 commit 7765834

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

categories.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,13 @@ var files = event.originalEvent.dataTransfer.files;
629629
<hr/>
630630
]]></desc>
631631
</category>
632+
<category name="Version 4.1" slug="4.1">
633+
<desc><![CDATA[
634+
<div id="version-support-warning" class="warning"><i class="icon-info-sign"></i> <span>This version has not been released yet. Behavior may change before the final release.</span></div>
635+
<p>All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.</p>
636+
<hr/>
637+
]]></desc>
638+
</category>
632639
<category name="All" slug="all"/>
633640
</category>
634641
</categories>

entries/jQuery.ajaxTransport.xml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ $.ajaxTransport( dataType, function( options, originalOptions, jqXHR ) {
4040
<li><code>headers</code> is an object of (key-value) request headers that the transport can transmit if it supports it</li>
4141
<li><code>completeCallback</code> is the callback used to notify Ajax of the completion of the request</li>
4242
</ul>
43-
<p><code>completeCallback</code> has the following signature:</p>
43+
<p>Since jQuery 4.1, <code>completeCallback</code> has the following signature:</p>
4444
<pre><code>
45-
function( status, statusText, responses, headers ) {}
45+
function( { status, statusText, responses, headers } ) {}
4646
</code></pre>
4747
<p>where:</p>
4848
<ul>
@@ -51,6 +51,11 @@ function( status, statusText, responses, headers ) {}
5151
<li><code>responses</code> (Optional) is An object containing dataType/value that contains the response in all the formats the transport could provide (for instance, a native XMLHttpRequest object would set responses to <code>{ xml: XMLData, text: textData }</code> for a response that is an XML document)</li>
5252
<li><code>headers</code> (Optional) is a string containing all the response headers if the transport has access to them (akin to what <code>XMLHttpRequest.getAllResponseHeaders()</code> would provide).</li>
5353
</ul>
54+
<p>An older, positional-arguments form is also supported:</p>
55+
<pre><code>
56+
function( status, statusText, responses, headers ) {}
57+
</code></pre>
58+
<p>The parameters have the same meaning as the object properties described above. Both calling conventions are supported; jQuery detects which one is used by checking whether the first argument is an object.</p>
5459
<p>Just like prefilters, a transport's factory function can be attached to a specific dataType:</p>
5560
<pre><code>
5661
$.ajaxTransport( "script", function( options, originalOptions, jqXHR ) {
@@ -70,7 +75,11 @@ $.ajaxTransport( "image", function( s ) {
7075
var statusText = ( status === 200 ) ? "success" : "error",
7176
tmp = image;
7277
image = image.onreadystatechange = image.onerror = image.onload = null;
73-
callback( status, statusText, { image: tmp } );
78+
callback( {
79+
status: status,
80+
statusText: statusText,
81+
responses: { image: tmp }
82+
} );
7483
}
7584
}
7685
image.onreadystatechange = image.onload = function() {
@@ -128,4 +137,5 @@ jQuery.ajaxSetup({
128137
</longdesc>
129138
<category slug="ajax/low-level-interface"/>
130139
<category slug="version/1.5"/>
140+
<category slug="version/4.1"/>
131141
</entry>

0 commit comments

Comments
 (0)