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 ) {
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" );
}
}
if ( s.global ) {
- trigger("ajaxSend", [xhr, s]);
+ contextTrigger("ajaxSend", [xhr, s]);
}
// Wait for a response to come back
// Fire the global callback
if ( s.global ) {
- trigger( "ajaxSuccess", [xhr, s] );
+ contextTrigger( "ajaxSuccess", [xhr, s] );
}
}
// The request was completed
if ( s.global ) {
- trigger( "ajaxComplete", [xhr, s] );
+ contextTrigger( "ajaxComplete", [xhr, s] );
}
// Handle the global AJAX counter
}
}
- function trigger(type, args) {
+ function contextTrigger(type, args) {
(s.context ? jQuery(s.context) : jQuery.event).trigger(type, args);
}