MCPcopy Index your code
hub / github.com/JsAaron/jQuery / buildParams

Function buildParams

1.7/ajax.js:801–831  ·  view source on GitHub ↗
( prefix, obj, traditional, add )

Source from the content-addressed store, hash-verified

799});
800
801function buildParams( prefix, obj, traditional, add ) {
802 if ( jQuery.isArray( obj ) ) {
803 // Serialize array item.
804 jQuery.each( obj, function( i, v ) {
805 if ( traditional || rbracket.test( prefix ) ) {
806 // Treat each array item as a scalar.
807 add( prefix, v );
808
809 } else {
810 // If array item is non-scalar (array or object), encode its
811 // numeric index to resolve deserialization ambiguity issues.
812 // Note that rack (as of 1.0.0) can't currently deserialize
813 // nested arrays properly, and attempting to do so may cause
814 // a server error. Possible fixes are to modify rack's
815 // deserialization algorithm or to provide an option or flag
816 // to force array serialization to be shallow.
817 buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add );
818 }
819 });
820
821 } else if ( !traditional && obj != null && typeof obj === "object" ) {
822 // Serialize object item.
823 for ( var name in obj ) {
824 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
825 }
826
827 } else {
828 // Serialize scalar item.
829 add( prefix, obj );
830 }
831}
832
833// This is still on the jQuery object... for now
834// Want to move this to jQuery.ajax some day

Callers 1

ajax.jsFile · 0.70

Calls 1

addFunction · 0.70

Tested by

no test coverage detected