MCPcopy Index your code
hub / github.com/jquery/jquery / buildParams

Function buildParams

dist-module/jquery.factory.slim.module.js:6210–6246  ·  view source on GitHub ↗
( prefix, obj, traditional, add )

Source from the content-addressed store, hash-verified

6208 rsubmittable = /^(?:input|select|textarea|keygen)/i;
6209
6210function buildParams( prefix, obj, traditional, add ) {
6211 var name;
6212
6213 if ( Array.isArray( obj ) ) {
6214
6215 // Serialize array item.
6216 jQuery.each( obj, function( i, v ) {
6217 if ( traditional || rbracket.test( prefix ) ) {
6218
6219 // Treat each array item as a scalar.
6220 add( prefix, v );
6221
6222 } else {
6223
6224 // Item is non-scalar (array or object), encode its numeric index.
6225 buildParams(
6226 prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
6227 v,
6228 traditional,
6229 add
6230 );
6231 }
6232 } );
6233
6234 } else if ( !traditional && toType( obj ) === "object" ) {
6235
6236 // Serialize object item.
6237 for ( name in obj ) {
6238 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
6239 }
6240
6241 } else {
6242
6243 // Serialize scalar item.
6244 add( prefix, obj );
6245 }
6246}
6247
6248// Serialize an array of form elements or a set of
6249// key/values into a query string

Callers 1

jQueryFactoryWrapperFunction · 0.70

Calls 2

addFunction · 0.70
toTypeFunction · 0.70

Tested by

no test coverage detected