Made some code tweaks related to running jQuery through JSLint (thanks to Lorin Larso...
[jquery.git] / src / ajax.js
index d0c6752..e17dfa8 100644 (file)
@@ -6,15 +6,15 @@ var jsc = now(),
        rquery = /\?/,
        rts = /(\?|&)_=.*?(&|$)/,
        rurl = /^(\w+:)?\/\/([^\/?#]+)/,
-       r20 = /%20/g;
+       r20 = /%20/g,
 
-jQuery.fn.extend({
-       // Keep a copy of the old load
-       _load: jQuery.fn.load,
+       // Keep a copy of the old load method
+       _load = jQuery.fn.load;
 
+jQuery.fn.extend({
        load: function( url, params, callback ) {
-               if ( typeof url !== "string" ) {
-                       return this._load( url );
+               if ( typeof url !== "string" && _load ) {
+                       return _load.apply( this, arguments );
 
                // Don't do a request if no elements are being requested
                } else if ( !this.length ) {
@@ -278,8 +278,10 @@ jQuery.extend({
                        s.url += (rquery.test(s.url) ? "&" : "?") + s.data;
                }
 
+               jQuery.active++;
+
                // Watch for a new set of requests
-               if ( s.global && ! jQuery.active++ ) {
+               if ( s.global && jQuery.active === 1 ) {
                        jQuery.event.trigger( "ajaxStart" );
                }
 
@@ -386,7 +388,7 @@ jQuery.extend({
                }
 
                if ( s.global ) {
-                       trigger("ajaxSend", [xhr, s]);
+                       contextTrigger("ajaxSend", [xhr, s]);
                }
 
                // Wait for a response to come back
@@ -499,7 +501,7 @@ jQuery.extend({
 
                        // Fire the global callback
                        if ( s.global ) {
-                               trigger( "ajaxSuccess", [xhr, s] );
+                               contextTrigger( "ajaxSuccess", [xhr, s] );
                        }
                }
 
@@ -511,7 +513,7 @@ jQuery.extend({
 
                        // The request was completed
                        if ( s.global ) {
-                               trigger( "ajaxComplete", [xhr, s] );
+                               contextTrigger( "ajaxComplete", [xhr, s] );
                        }
 
                        // Handle the global AJAX counter
@@ -520,7 +522,7 @@ jQuery.extend({
                        }
                }
                
-               function trigger(type, args) {
+               function contextTrigger(type, args) {
                        (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args);
                }
 
@@ -635,7 +637,7 @@ jQuery.extend({
                        if ( jQuery.isArray(obj) ) {
                                // Serialize array item.
                                jQuery.each( obj, function( i, v ) {
-                                       if ( traditional ) {
+                                       if ( traditional || /\[\]$/.test( prefix ) ) {
                                                // Treat each array item as a scalar.
                                                add( prefix, v );
                                        } else {