X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fajax%2Fajax.js;h=ffe30481d37e956024115124454c52801b82f9eb;hb=f96bf1041553775a94c1034c97e253e350217173;hp=62785f355c9320ab652f3464f2c4532b7fbb0bfe;hpb=139393fe0978e79c427ad13f1a03a10431ef95e5;p=jquery.git diff --git a/src/ajax/ajax.js b/src/ajax/ajax.js index 62785f3..ffe3048 100644 --- a/src/ajax/ajax.js +++ b/src/ajax/ajax.js @@ -1,10 +1,5 @@ jQuery.fn.extend({ - // DEPRECATED - loadIfModified: function( url, params, callback ) { - this.load( url, params, callback, 1 ); - }, - - load: function( url, params, callback, ifModified ) { + load: function( url, params, callback ) { if ( jQuery.isFunction( url ) ) return this.bind("load", url); @@ -40,10 +35,9 @@ jQuery.fn.extend({ url: url, type: type, data: params, - ifModified: ifModified, complete: function(res, status){ // If successful, inject the HTML into all the matched elements - if ( status == "success" || !ifModified && status == "notmodified" ) + if ( status == "success" || status == "notmodified" ) // See if a selector was specified self.html( selector ? // Create a dummy div to hold the results @@ -68,14 +62,25 @@ jQuery.fn.extend({ }, serialize: function() { - return jQuery.param( this ); + return jQuery.param(this.serializeArray()); }, - - // DEPRECATED - // This method no longer does anything - all script evaluation is - // taken care of within the HTML injection methods. - evalScripts: function(){} - + serializeArray: function() { + return this.map(function(){ + return jQuery.nodeName(this, "form") ? + jQuery.makeArray(this.elements) : this; + }) + .filter(function(){ + return this.name && !this.disabled && + (this.checked || /select|textarea/i.test(this.nodeName) || + /text|hidden|password/i.test(this.type)); + }) + .map(function(i, elem){ var val = jQuery(this).val(); + return val == null ? null : + val.constructor == Array ? + jQuery.map( val, function(i, val){ return {name: elem.name, value: val}; + }) : + {name: elem.name, value: val}; + }).get(); } }); // Attach a bunch of functions for handling common AJAX events @@ -88,7 +93,7 @@ jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".sp var jsc = (new Date).getTime(); jQuery.extend({ - get: function( url, data, callback, type, ifModified ) { + get: function( url, data, callback, type ) { // shift arguments if data argument was ommited if ( jQuery.isFunction( data ) ) { callback = data; @@ -100,16 +105,10 @@ jQuery.extend({ url: url, data: data, success: callback, - dataType: type, - ifModified: ifModified + dataType: type }); }, - // DEPRECATED - getIfModified: function( url, data, callback, type ) { - return jQuery.get(url, data, callback, type, 1); - }, - getScript: function( url, callback ) { return jQuery.get(url, null, callback, "script"); }, @@ -133,11 +132,6 @@ jQuery.extend({ }); }, - // DEPRECATED - ajaxTimeout: function( timeout ) { - jQuery.ajaxSettings.timeout = timeout; - }, - ajaxSetup: function( settings ) { jQuery.extend( jQuery.ajaxSettings, settings ); }, @@ -462,7 +456,7 @@ jQuery.extend({ s.push( encodeURIComponent(j) + "=" + encodeURIComponent( a[j] ) ); // Return the resulting serialization - return s.join("&"); + return s.join("&").replace(/%20/g, "+"); } });