- // Serialize the key/values
- for ( var j in a )
- // 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 ) );
+ // Encode parameters from object, recursively. If
+ // jQuery.param.traditional is set, encode the "old" way
+ // (the way 1.3.2 or older did it)
+ jQuery.each( a, function buildParams( prefix, obj ) {
+
+ if ( jQuery.isArray(obj) )
+ jQuery.each( obj, function(i,v){
+ // Due to rails' limited request param syntax, numeric array
+ // indices are not supported. To avoid serialization ambiguity
+ // issues, serialized arrays can only contain scalar values. php
+ // does not have this issue, but we should go with the lowest
+ // common denominator
+ add( prefix + ( param_traditional ? "" : "[]" ), v );