X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fajax.js;h=11eacee7190e92cf69ee3dc3ed724a9bb13a3afe;hb=485fa0c42a71b4decc9cb1ce08bb56efabcc76f3;hp=383ba2b1ff8543f824cbb0ce9b3a966800527779;hpb=bbd3f4f3fe66fc4ce6c6db31a17a1c04037323be;p=jquery.git diff --git a/src/ajax.js b/src/ajax.js index 383ba2b..11eacee 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -48,7 +48,7 @@ function addToPrefiltersOrTransports( structure ) { } if ( jQuery.isFunction( func ) ) { - var dataTypes = dataTypeExpression.split( rspacesAjax ), + var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ), i = 0, length = dataTypes.length, dataType, @@ -62,7 +62,7 @@ function addToPrefiltersOrTransports( structure ) { // any existing element placeBefore = /^\+/.test( dataType ); if ( placeBefore ) { - dataType = dataType.substr( 1 ); + dataType = dataType.substr( 1 ) || "*"; } list = structure[ dataType ] = structure[ dataType ] || []; // then we add to the structure accordingly @@ -334,13 +334,17 @@ jQuery.extend({ var // Create the final options object s = jQuery.extend( true, {}, jQuery.ajaxSettings, options ), - // Callbacks contexts + // Callbacks context // We force the original context if it exists // or take it from jQuery.ajaxSettings otherwise // (plain objects used as context get extended) callbackContext = ( s.context = ( "context" in options ? options : jQuery.ajaxSettings ).context ) || s, - globalEventContext = callbackContext === s ? jQuery.event : jQuery( callbackContext ), + // Context for global events + // It's the callbackContext if one was provided in the options + // and if it's a DOM node + globalEventContext = callbackContext !== s && callbackContext.nodeType ? + jQuery( callbackContext ) : jQuery.event, // Deferreds deferred = jQuery.Deferred(), completeDeferred = jQuery._Deferred(), @@ -736,9 +740,9 @@ function buildParams( prefix, obj, traditional, add ) { // Serialize object item. } else { - jQuery.each( obj, function( k, v ) { - buildParams( prefix + "[" + k + "]", v, traditional, add ); - }); + for ( var name in obj ) { + buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); + } } } else {