git.asbjorn.biz
/
jquery.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3e1d3d0
)
Renames determineDataType as determineResponse. Makes it more generic as a first...
author
jaubourg
<j@ubourg.net>
Thu, 20 Jan 2011 16:38:21 +0000
(17:38 +0100)
committer
jaubourg
<j@ubourg.net>
Thu, 20 Jan 2011 16:38:21 +0000
(17:38 +0100)
src/ajax.js
patch
|
blob
|
history
src/ajax/xhr.js
patch
|
blob
|
history
diff --git
a/src/ajax.js
b/src/ajax.js
index
dd3c50d
..
955856c
100644
(file)
--- a/
src/ajax.js
+++ b/
src/ajax.js
@@
-235,7
+235,7
@@
jQuery.extend({
// Utility function that handles dataType when response is received
// (for those transports that can give text or xml responses)
// Utility function that handles dataType when response is received
// (for those transports that can give text or xml responses)
- determineDataType: function( ct , text , xml ) {
+ determineResponse: function( responses , ct ) {
var s = this,
contents = s.contents,
var s = this,
contents = s.contents,
@@
-246,7
+246,7
@@
jQuery.extend({
response;
// Auto (xml, json, script or text determined given headers)
response;
// Auto (xml, json, script or text determined given headers)
- if ( transportDataType === "*" ) {
+ if ( ct && transportDataType === "*" ) {
for ( type in contents ) {
if ( ( regexp = contents[ type ] ) && regexp.test( ct ) ) {
for ( type in contents ) {
if ( ( regexp = contents[ type ] ) && regexp.test( ct ) ) {
@@
-256,23
+256,22
@@
jQuery.extend({
}
}
}
}
- // xml and parsed as such
- if ( transportDataType === "xml" &&
- xml &&
- xml.documentElement /* #4958 */ ) {
-
- response = xml;
-
- // Text response was provided
- } else {
+ // Get response
+ for( type in responses ) {
+ if ( type === transportDataType ) {
+ break;
+ }
+ }
- response = text;
+ // Get final response
+ response = responses[ type ];
- // If it's not really text, defer to converters
- if ( transportDataType !== "text" ) {
- dataTypes.unshift( "text" );
+ // If it's not the right dataType, handle the dataTypeList
+ if ( transportDataType !== type ) {
+ if ( transportDataType === "*" ) {
+ dataTypes.shift();
}
}
-
+ dataTypes.unshift( type );
}
return response;
}
return response;
diff --git
a/src/ajax/xhr.js
b/src/ajax/xhr.js
index
4acb700
..
cd9838c
100644
(file)
--- a/
src/ajax/xhr.js
+++ b/
src/ajax/xhr.js
@@
-12,8
+12,8
@@
var // Next active xhr id
// XHR used to determine supports properties
testXHR;
// XHR used to determine supports properties
testXHR;
-// Create the request object; Microsoft failed to properly
-// (This is still attached to ajaxSettings for backward compatibility reasons)
+// Create the request object
+// (This is still attached to ajaxSettings for backward compatibility)
jQuery.ajaxSettings.xhr = window.ActiveXObject ?
/* Microsoft failed to properly
* implement the XMLHttpRequest in IE7 (can't request local files),
jQuery.ajaxSettings.xhr = window.ActiveXObject ?
/* Microsoft failed to properly
* implement the XMLHttpRequest in IE7 (can't request local files),
@@
-146,8
+146,9
@@
if ( jQuery.support.ajax ) {
// Get info
var status = xhr.status,
statusText,
// Get info
var status = xhr.status,
statusText,
- response,
- responseHeaders = xhr.getAllResponseHeaders();
+ responseHeaders = xhr.getAllResponseHeaders(),
+ responses = {},
+ xml = xhr.responseXML;
try { // Firefox throws an exception when accessing statusText for faulty cross-domain requests
try { // Firefox throws an exception when accessing statusText for faulty cross-domain requests
@@
-184,15
+185,15
@@
if ( jQuery.support.ajax ) {
status
);
status
);
- // Guess response & update dataType accordingly
- response =
- s.determineDataType(
- xhr.getResponseHeader("content-type"),
- xhr.responseText,
- xhr.responseXML );
+ // Construct response list
+ if ( xml && xml.documentElement /* #4958 */ ) {
+ responses.xml = xml;
+ }
+ responses.text = xhr.responseText;
// Call complete
// Call complete
- complete(status,statusText,response,responseHeaders);
+ complete(status,statusText,s.determineResponse( responses,
+ xhr.getResponseHeader( "content-type" ) ),responseHeaders);
}
}
};
}
}
};