Fixed ajax array arguments in $.param
[jquery.git] / src / ajax / ajax.js
index 4b1e9b0..c8e10bd 100644 (file)
@@ -77,7 +77,7 @@ jQuery.fn.extend({
                        complete: function(res, status){
                                // If successful, inject the HTML into all the matched elements
                                if ( status == "success" || !ifModified && status == "notmodified" )
-                                       self.html(res.responseText)
+                                       self.html(res.responseText);
 
                                self.each( callback, [res.responseText, status, res] );
                        }
@@ -662,7 +662,7 @@ jQuery.extend({
                                        } else
                                                jQuery.handleError(s, xml, status);
                                } catch(e) {
-                                       status = "error";
+                                       status = "parsererror";
                                        jQuery.handleError(s, xml, status, e);
                                }
 
@@ -757,8 +757,11 @@ jQuery.extend({
         */
        httpData: function( r, type ) {
                var ct = r.getResponseHeader("content-type");
-               var data = !type && ct && ct.indexOf("xml") >= 0;
-               data = type == "xml" || data ? r.responseXML : r.responseText;
+               var xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0;
+               data = xml ? r.responseXML : r.responseText;
+
+               if ( xml && data.documentElement.tagName == "parsererror" )
+                       throw "parsererror";
 
                // If the type is "script", eval it in global context
                if ( type == "script" )
@@ -791,7 +794,7 @@ jQuery.extend({
                                // If the value is an array then the key names need to be repeated
                                if ( a[j] && a[j].constructor == Array )
                                        jQuery.each( a[j], function(){
-                                               s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) );
+                                               s.push( encodeURIComponent(j) + "[]=" + encodeURIComponent( this ) );
                                        });
                                else
                                        s.push( encodeURIComponent(j) + "=" + encodeURIComponent( a[j] ) );