git.asbjorn.biz
/
jquery.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Removes misleading comment.
[jquery.git]
/
src
/
ajax.js
diff --git
a/src/ajax.js
b/src/ajax.js
index
fc1ecfd
..
a92522f
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;
@@
-291,18
+290,16
@@
jQuery.extend({
// Main method
ajax: function( url , options ) {
// Main method
ajax: function( url , options ) {
- // Handle varargs
- if ( arguments.length === 1 ) {
+ // If options is not an object,
+ // we simulate pre-1.5 signature
+ if ( typeof( options ) !== "object" ) {
options = url;
options = url;
- url = options ? options.url : undefined;
+ url = undefined;
}
// Force options to be an object
options = options || {};
}
// Force options to be an object
options = options || {};
- // Get the url if provided separately
- options.url = url || options.url;
-
var // Create the final options object
s = jQuery.extend( true , {} , jQuery.ajaxSettings , options ),
// jQuery lists
var // Create the final options object
s = jQuery.extend( true , {} , jQuery.ajaxSettings , options ),
// jQuery lists
@@
-427,10
+424,8
@@
jQuery.extend({
// Stored error
error,
// Stored error
error,
- // Keep track of statusCode callbacks
- oldStatusCode = statusCode;
-
- statusCode = undefined;
+ // To keep track of statusCode based callbacks
+ oldStatusCode;
// If successful, handle type chaining
if ( status >= 200 && status < 300 || status === 304 ) {
// If successful, handle type chaining
if ( status >= 200 && status < 300 || status === 304 ) {
@@
-582,12
+577,14
@@
jQuery.extend({
// Success/Error
if ( isSuccess ) {
// Success/Error
if ( isSuccess ) {
- deferred.fire( callbackContext , [ success , statusText , jXHR ] );
+ deferred.resolveWith( callbackContext , [ success , statusText , jXHR ] );
} else {
} else {
- deferred.fireReject( callbackContext , [ jXHR , statusText , error ] );
+ deferred.rejectWith( callbackContext , [ jXHR , statusText , error ] );
}
// Status-dependent callbacks
}
// Status-dependent callbacks
+ oldStatusCode = statusCode;
+ statusCode = undefined;
jXHR.statusCode( oldStatusCode );
if ( s.global ) {
jXHR.statusCode( oldStatusCode );
if ( s.global ) {
@@
-596,7
+593,7
@@
jQuery.extend({
}
// Complete
}
// Complete
- completeDeferred.fire( callbackContext, [ jXHR , statusText ] );
+ completeDeferred.resolveWith( callbackContext, [ jXHR , statusText ] );
if ( s.global ) {
globalEventContext.trigger( "ajaxComplete" , [ jXHR , s] );
if ( s.global ) {
globalEventContext.trigger( "ajaxComplete" , [ jXHR , s] );
@@
-630,7
+627,8
@@
jQuery.extend({
};
// Remove hash character (#7531: and string promotion)
};
// Remove hash character (#7531: and string promotion)
- s.url = ( "" + s.url ).replace( rhash , "" );
+ // We also use the url parameter if available
+ s.url = ( "" + ( url || s.url ) ).replace( rhash , "" );
// Extract dataTypes list
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( /\s+/ );
// Extract dataTypes list
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( /\s+/ );