| 7355 | }); |
| 7356 | |
| 7357 | function buildParams( prefix, obj, traditional, add ) { |
| 7358 | if ( jQuery.isArray( obj ) ) { |
| 7359 | // Serialize array item. |
| 7360 | jQuery.each( obj, function( i, v ) { |
| 7361 | if ( traditional || rbracket.test( prefix ) ) { |
| 7362 | // Treat each array item as a scalar. |
| 7363 | add( prefix, v ); |
| 7364 | |
| 7365 | } else { |
| 7366 | // If array item is non-scalar (array or object), encode its |
| 7367 | // numeric index to resolve deserialization ambiguity issues. |
| 7368 | // Note that rack (as of 1.0.0) can't currently deserialize |
| 7369 | // nested arrays properly, and attempting to do so may cause |
| 7370 | // a server error. Possible fixes are to modify rack's |
| 7371 | // deserialization algorithm or to provide an option or flag |
| 7372 | // to force array serialization to be shallow. |
| 7373 | buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add ); |
| 7374 | } |
| 7375 | }); |
| 7376 | |
| 7377 | } else if ( !traditional && obj != null && typeof obj === "object" ) { |
| 7378 | // Serialize object item. |
| 7379 | for ( var name in obj ) { |
| 7380 | buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); |
| 7381 | } |
| 7382 | |
| 7383 | } else { |
| 7384 | // Serialize scalar item. |
| 7385 | add( prefix, obj ); |
| 7386 | } |
| 7387 | } |
| 7388 | |
| 7389 | // This is still on the jQuery object... for now |
| 7390 | // Want to move this to jQuery.ajax some day |