Renames determineDataType as determineResponse. Makes it more generic as a first step into integrating the logic into the main ajax done callback. Also fixes some comments in ajax/xhr.js.
This commit is contained in:
parent
3e1d3d0f21
commit
ef86694ada
2 changed files with 28 additions and 28 deletions
33
src/ajax.js
33
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)
|
||||
determineDataType: function( ct , text , xml ) {
|
||||
determineResponse: function( responses , ct ) {
|
||||
|
||||
var s = this,
|
||||
contents = s.contents,
|
||||
|
@ -246,7 +246,7 @@ jQuery.extend({
|
|||
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 ) ) {
|
||||
|
@ -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 {
|
||||
|
||||
response = text;
|
||||
|
||||
// If it's not really text, defer to converters
|
||||
if ( transportDataType !== "text" ) {
|
||||
dataTypes.unshift( "text" );
|
||||
// Get response
|
||||
for( type in responses ) {
|
||||
if ( type === transportDataType ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Get final response
|
||||
response = responses[ type ];
|
||||
|
||||
// If it's not the right dataType, handle the dataTypeList
|
||||
if ( transportDataType !== type ) {
|
||||
if ( transportDataType === "*" ) {
|
||||
dataTypes.shift();
|
||||
}
|
||||
dataTypes.unshift( type );
|
||||
}
|
||||
|
||||
return response;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue