X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fajax.js;h=08fa08b31e55225227e69e00f88f801415f46bfb;hb=a45372a4c5cfd33c4ff12b145bd79fec2fe0d382;hp=ee52ed82f5e75bcb9161aa4a02fc2203daa59271;hpb=f91b944cabf7be9aadb40ffe35fce76b50f5f25f;p=jquery.git diff --git a/src/ajax.js b/src/ajax.js index ee52ed8..08fa08b 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -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 ) { @@ -206,7 +206,7 @@ jQuery.extend({ var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings); var jsonp, status, data, - callbackContext = s.context || s, + callbackContext = origSettings && origSettings.context || s, type = s.type.toUpperCase(); // convert data if not already a string @@ -417,13 +417,16 @@ jQuery.extend({ "notmodified" : "success"; + var errMsg; + if ( status === "success" ) { // Watch for, and catch, XML document parse errors try { // process the data (runs the xml through httpData regardless of callback) data = jQuery.httpData( xhr, s.dataType, s ); - } catch(e) { + } catch(err) { status = "parsererror"; + errMsg = err; } } @@ -434,7 +437,7 @@ jQuery.extend({ success(); } } else { - jQuery.handleError(s, xhr, status); + jQuery.handleError(s, xhr, status, errMsg); } // Fire the complete handlers @@ -632,7 +635,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 {