| 7229 | }; |
| 7230 | |
| 7231 | function buildParams( prefix, obj, traditional, add ) { |
| 7232 | var name; |
| 7233 | |
| 7234 | if ( jQuery.isArray( obj ) ) { |
| 7235 | // Serialize array item. |
| 7236 | jQuery.each( obj, function( i, v ) { |
| 7237 | if ( traditional || rbracket.test( prefix ) ) { |
| 7238 | // Treat each array item as a scalar. |
| 7239 | add( prefix, v ); |
| 7240 | |
| 7241 | } else { |
| 7242 | // If array item is non-scalar (array or object), encode its |
| 7243 | // numeric index to resolve deserialization ambiguity issues. |
| 7244 | // Note that rack (as of 1.0.0) can't currently deserialize |
| 7245 | // nested arrays properly, and attempting to do so may cause |
| 7246 | // a server error. Possible fixes are to modify rack's |
| 7247 | // deserialization algorithm or to provide an option or flag |
| 7248 | // to force array serialization to be shallow. |
| 7249 | buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add ); |
| 7250 | } |
| 7251 | }); |
| 7252 | |
| 7253 | } else if ( !traditional && jQuery.type( obj ) === "object" ) { |
| 7254 | // Serialize object item. |
| 7255 | for ( name in obj ) { |
| 7256 | buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); |
| 7257 | } |
| 7258 | |
| 7259 | } else { |
| 7260 | // Serialize scalar item. |
| 7261 | add( prefix, obj ); |
| 7262 | } |
| 7263 | } |
| 7264 | var |
| 7265 | // Document location |
| 7266 | ajaxLocParts, |