jquery event: fixed $.fn.load, closes #2819.
[jquery.git] / src / ajax.js
index ca17f4f..e0ab7f4 100644 (file)
@@ -1,7 +1,10 @@
 jQuery.fn.extend({
+       // Keep a copy of the old load
+       _load: jQuery.fn.load,
+       
        load: function( url, params, callback ) {
-               if ( jQuery.isFunction( url ) )
-                       return this.bind("load", url);
+               if ( typeof url != 'string' )
+                       return this._load( url );
 
                var off = url.indexOf(" ");
                if ( off >= 0 ) {
@@ -91,7 +94,7 @@ jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".sp
        };
 });
 
-var jsc = (new Date).getTime();
+var jsc = now();
 
 jQuery.extend({
        get: function( url, data, callback, type ) {
@@ -211,7 +214,7 @@ jQuery.extend({
                        s.cache = false;
 
                if ( s.cache === false && s.type.toLowerCase() == "get" ) {
-                       var ts = (new Date()).getTime();
+                       var ts = now();
                        // try replacing _= if it is there
                        var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2");
                        // if nothing was replaced, add timestamp to the end
@@ -448,9 +451,9 @@ jQuery.extend({
        },
 
        httpData: function( r, type ) {
-               var ct = r.getResponseHeader("content-type");
-               var xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0;
-               var data = xml ? r.responseXML : r.responseText;
+               var ct = r.getResponseHeader("content-type"),
+                       xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0,
+                       data = xml ? r.responseXML : r.responseText;
 
                if ( xml && data.documentElement.tagName == "parsererror" )
                        throw "parsererror";
@@ -489,7 +492,7 @@ jQuery.extend({
                                                s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) );
                                        });
                                else
-                                       s.push( encodeURIComponent(j) + "=" + encodeURIComponent( a[j] ) );
+                                       s.push( encodeURIComponent(j) + "=" + encodeURIComponent( jQuery.isFunction(a[j]) ? a[j]() : a[j] ) );
 
                // Return the resulting serialization
                return s.join("&").replace(/%20/g, "+");