X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;ds=sidebyside;f=src%2Fajax.js;h=d7237fc3fb13fcfc08dac9c18bff78046cbe5ad2;hb=11761def421412df7ea4d3414310befef450b7ea;hp=a0c80afe6c03571e2cc7df6c3adaba02da929412;hpb=afc2ebde1425722f4e2df14919c0df0ff7d2ff0c;p=jquery.git diff --git a/src/ajax.js b/src/ajax.js index a0c80af..d7237fc 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -26,7 +26,7 @@ jQuery.fn.extend({ params = null; // Otherwise, build a param string - } else { + } else if( typeof params == 'object' ) { params = jQuery.param( params ); type = "POST"; } @@ -327,9 +327,9 @@ jQuery.extend({ ival = null; } - status = isTimeout == "timeout" && "timeout" || - !jQuery.httpSuccess( xhr ) && "error" || - s.ifModified && jQuery.httpNotModified( xhr, s.url ) && "notmodified" || + status = isTimeout == "timeout" ? "timeout" : + !jQuery.httpSuccess( xhr ) ? "error" : + s.ifModified && jQuery.httpNotModified( xhr, s.url ) ? "notmodified" : "success"; if ( status == "success" ) { @@ -486,14 +486,18 @@ jQuery.extend({ // Serialize an array of form elements or a set of // key/values into a query string param: function( a ) { - var s = []; + var s = [ ]; + + function add( key, value ){ + s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value); + }; // If an array was passed in, assume that it is an array // of form elements if ( a.constructor == Array || a.jquery ) // Serialize the form elements jQuery.each( a, function(){ - s.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( this.value ) ); + add( this.name, this.value ); }); // Otherwise, assume that it's an object of key/value pairs @@ -503,10 +507,10 @@ jQuery.extend({ // If the value is an array then the key names need to be repeated if ( a[j] && a[j].constructor == Array ) jQuery.each( a[j], function(){ - s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) ); + add( j, this ); }); else - s.push( encodeURIComponent(j) + "=" + encodeURIComponent( jQuery.isFunction(a[j]) ? a[j]() : a[j] ) ); + add( j, jQuery.isFunction(a[j]) ? a[j]() : a[j] ); // Return the resulting serialization return s.join("&").replace(/%20/g, "+");