]> source.dussan.org Git - jquery.git/commitdiff
if one value of key/value pairs is array then treat each array value in part
authorStefan Petre <stefan.petre@gmail.com>
Thu, 16 Nov 2006 10:30:14 +0000 (10:30 +0000)
committerStefan Petre <stefan.petre@gmail.com>
Thu, 16 Nov 2006 10:30:14 +0000 (10:30 +0000)
src/ajax/ajax.js

index f9d46503ab42bc83d84a18bad5b82bb629d4f602..42bc54b6ea5ab04af06762214103afcd6a66f17b 100644 (file)
@@ -892,8 +892,15 @@ jQuery.extend({
                // Otherwise, assume that it's an object of key/value pairs
                } else {
                        // Serialize the key/values
-                       for ( var j in a )
-                               s.push( j + "=" + encodeURIComponent( a[j] ) );
+                       for ( var j in a ) {
+                               //if one value is array then treat each array value in part
+                               if (typeof a[j] == 'object') {
+                                       for (var k = 0; k < a[j].length; k++) {
+                                               s.push( j + "[]=" + encodeURIComponent( a[j][k] ) );
+                                       }
+                               } else {
+                                       s.push( j + "=" + encodeURIComponent( a[j] ) );
+                               }
                }
 
                // Return the resulting serialization