X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fajax.js;h=bac0ab18267aee00c65a5a105337fc2ae823a0f2;hb=1830db422628d1556377621612b401bac5afa40e;hp=ceeef5eb4b8563571381ee027bc130e0fc7679a5;hpb=ab3ba4a81252c4357a7aab5f24d765d41d47986e;p=jquery.git diff --git a/src/ajax.js b/src/ajax.js index ceeef5e..bac0ab1 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -113,9 +113,8 @@ jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".sp }; }); -jQuery.extend({ - - get: function( url, data, callback, type ) { +jQuery.each( [ "GET", "POST" ], function( i, method ) { + jQuery[ method.toLowerCase() ] = function( url, data, callback, type ) { // shift arguments if data argument was omited if ( jQuery.isFunction( data ) ) { type = type || callback; @@ -124,13 +123,16 @@ jQuery.extend({ } return jQuery.ajax({ - type: "GET", + type: method, url: url, data: data, success: callback, dataType: type }); - }, + }; +}); + +jQuery.extend({ getScript: function( url, callback ) { return jQuery.get(url, null, callback, "script"); @@ -140,23 +142,6 @@ jQuery.extend({ return jQuery.get(url, data, callback, "json"); }, - post: function( url, data, callback, type ) { - // shift arguments if data argument was omited - if ( jQuery.isFunction( data ) ) { - type = type || callback; - callback = data; - data = {}; - } - - return jQuery.ajax({ - type: "POST", - url: url, - data: data, - success: callback, - dataType: type - }); - }, - ajaxSetup: function( settings ) { jQuery.extend( jQuery.ajaxSettings, settings ); }, @@ -343,7 +328,9 @@ function buildParams( prefix, obj, traditional, add ) { }); } else if ( !traditional && obj != null && typeof obj === "object" ) { - if ( jQuery.isEmptyObject( obj ) ) { + // If we see an array here, it is empty and should be treated as an empty + // object + if ( jQuery.isArray( obj ) || jQuery.isEmptyObject( obj ) ) { add( prefix, "" ); // Serialize object item. @@ -401,4 +388,4 @@ jQuery.support.ajax = !!testXHR; // Does this browser support crossDomain XHR requests jQuery.support.cors = testXHR && "withCredentials" in testXHR; -})(jQuery); \ No newline at end of file +})( jQuery );