Make sure that we don't try to double-encode params using the traditional style....
[jquery.git] / src / ajax.js
index ee52ed8..f514cae 100644 (file)
@@ -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
@@ -621,7 +624,7 @@ jQuery.extend({
                        // If traditional, encode the "old" way (the way 1.3.2 or older
                        // did it), otherwise encode params recursively.
                        for ( var prefix in a ) {
-                               buildParams( prefix, a[prefix] );
+                               buildParams( traditional ? prefix : prefix.replace(/[\[\]]/g, ""), a[prefix] );
                        }
                }