Adding in .bind(name, false), .unbind(name, false) support - an easy way to just...
[jquery.git] / src / ajax.js
index ee52ed8..08fa08b 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 ) {
@@ -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 {