MCPcopy Create free account
hub / github.com/frank-lam/fullstack-tutorial / buildParams

Function buildParams

notes/docsify/unpkg/gotop/jquery-2.1.0.js:8350–8376  ·  view source on GitHub ↗
( prefix, obj, traditional, add )

Source from the content-addressed store, hash-verified

8348 rsubmittable = /^(?:input|select|textarea|keygen)/i;
8349
8350function buildParams( prefix, obj, traditional, add ) {
8351 var name;
8352
8353 if ( jQuery.isArray( obj ) ) {
8354 // Serialize array item.
8355 jQuery.each( obj, function( i, v ) {
8356 if ( traditional || rbracket.test( prefix ) ) {
8357 // Treat each array item as a scalar.
8358 add( prefix, v );
8359
8360 } else {
8361 // Item is non-scalar (array or object), encode its numeric index.
8362 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
8363 }
8364 });
8365
8366 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
8367 // Serialize object item.
8368 for ( name in obj ) {
8369 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
8370 }
8371
8372 } else {
8373 // Serialize scalar item.
8374 add( prefix, obj );
8375 }
8376}
8377
8378// Serialize an array of form elements or a set of
8379// key/values into a query string

Callers 1

jquery-2.1.0.jsFile · 0.85

Calls 1

addFunction · 0.85

Tested by

no test coverage detected