| 7683 | }); |
| 7684 | |
| 7685 | function buildParams( prefix, obj, traditional, add ) { |
| 7686 | if ( jQuery.isArray( obj ) ) { |
| 7687 | // Serialize array item. |
| 7688 | jQuery.each( obj, function( i, v ) { |
| 7689 | if ( traditional || rbracket.test( prefix ) ) { |
| 7690 | // Treat each array item as a scalar. |
| 7691 | add( prefix, v ); |
| 7692 | |
| 7693 | } else { |
| 7694 | // If array item is non-scalar (array or object), encode its |
| 7695 | // numeric index to resolve deserialization ambiguity issues. |
| 7696 | // Note that rack (as of 1.0.0) can't currently deserialize |
| 7697 | // nested arrays properly, and attempting to do so may cause |
| 7698 | // a server error. Possible fixes are to modify rack's |
| 7699 | // deserialization algorithm or to provide an option or flag |
| 7700 | // to force array serialization to be shallow. |
| 7701 | buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add ); |
| 7702 | } |
| 7703 | }); |
| 7704 | |
| 7705 | } else if ( !traditional && obj != null && typeof obj === "object" ) { |
| 7706 | // Serialize object item. |
| 7707 | for ( var name in obj ) { |
| 7708 | buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); |
| 7709 | } |
| 7710 | |
| 7711 | } else { |
| 7712 | // Serialize scalar item. |
| 7713 | add( prefix, obj ); |
| 7714 | } |
| 7715 | } |
| 7716 | |
| 7717 | // This is still on the jQuery object... for now |
| 7718 | // Want to move this to jQuery.ajax some day |