X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fajax.js;h=18ea203d0e5bf80df494484b1c8df13b70776174;hb=01cba2ecaaedb5351f668bb09026db3e8bb69082;hp=da130faed407be1fdcbd80496d1955f9d059cfeb;hpb=ab74d8e6a0810717419abb696154d034ad145f2b;p=jquery.git diff --git a/src/ajax.js b/src/ajax.js index da130fa..18ea203 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 ] = 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.