X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fajax.js;h=955856cc269c678552822293568b52f404bddcba;hb=ef86694ada757e5bc14227f8e5cc7d9d3a771da2;hp=dd3c50d80f2a213dfbcdccd7c9d8117177cb70c8;hpb=3e1d3d0f21d1b292fe721b4f483b3a3bc2dadd86;p=jquery.git diff --git a/src/ajax.js b/src/ajax.js index dd3c50d..955856c 100644 --- 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) - 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 { + // 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;