From ff75c91b58e80ae516494cdf28cdecbee1af6446 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski-Owczarek?=
All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
]]>
+
+ ]]>
All the aspects of the API that were added, or had a new signature added, in the corresponding version of jQuery.
+responseXML and/or responseText when the underlying request responded with xml and/or text, respectively
responseURL (as of jQuery 4.1) is the final URL of the response after any redirects, when the underlying transport reports it. For XMLHttpRequest-based requests in modern browsers, this mirrors XMLHttpRequest.responseURL; for script, JSONP, aborted, or otherwise unsupported requests it is undefined.
+ status
headers is an object of (key-value) request headers that the transport can transmit if it supports itcompleteCallback is the callback used to notify Ajax of the completion of the requestcompleteCallback has the following signature:
In jQuery 3.8, 4.1 or newer completeCallback accepts a single params object:
-function( status, statusText, responses, headers ) {}
+function( params ) {}
- where:
+with the following properties:
status is the HTTP status code of the response, like 200 for a typical success, or 404 for when the resource is not found.statusText is the statusText of the response.responses (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 { xml: XMLData, text: textData } for a response that is an XML document)headers (Optional) is a string containing all the response headers if the transport has access to them (akin to what XMLHttpRequest.getAllResponseHeaders() would provide).responseURL (Optional, as of jQuery 4.1) is the final URL of the response after any redirects, if the transport has access to it (akin to what XMLHttpRequest.responseURL would provide). It is exposed on the jqXHR object as jqXHR.responseURL.An older, positional-arguments form is also supported, but limited to the following four parameters:
+
+function( status, statusText, responses, headers ) {}
+
+ 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.
Just like prefilters, a transport's factory function can be attached to a specific dataType:
$.ajaxTransport( "script", function( options, originalOptions, jqXHR ) {
@@ -70,7 +76,11 @@ $.ajaxTransport( "image", function( s ) {
var statusText = ( status === 200 ) ? "success" : "error",
tmp = image;
image = image.onreadystatechange = image.onerror = image.onload = null;
- callback( status, statusText, { image: tmp } );
+ callback( {
+ status: status,
+ statusText: statusText,
+ responses: { image: tmp }
+ } );
}
}
image.onreadystatechange = image.onload = function() {
@@ -128,4 +138,6 @@ jQuery.ajaxSetup({
+
+