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

Function buildParams

dist-module/jquery.module.js:7800–7836  ·  view source on GitHub ↗
( prefix, obj, traditional, add )

Source from the content-addressed store, hash-verified

7798 rsubmittable = /^(?:input|select|textarea|keygen)/i;
7799
7800function buildParams( prefix, obj, traditional, add ) {
7801 var name;
7802
7803 if ( Array.isArray( obj ) ) {
7804
7805 // Serialize array item.
7806 jQuery.each( obj, function( i, v ) {
7807 if ( traditional || rbracket.test( prefix ) ) {
7808
7809 // Treat each array item as a scalar.
7810 add( prefix, v );
7811
7812 } else {
7813
7814 // Item is non-scalar (array or object), encode its numeric index.
7815 buildParams(
7816 prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
7817 v,
7818 traditional,
7819 add
7820 );
7821 }
7822 } );
7823
7824 } else if ( !traditional && toType( obj ) === "object" ) {
7825
7826 // Serialize object item.
7827 for ( name in obj ) {
7828 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
7829 }
7830
7831 } else {
7832
7833 // Serialize scalar item.
7834 add( prefix, obj );
7835 }
7836}
7837
7838// Serialize an array of form elements or a set of
7839// key/values into a query string

Callers 1

jQueryFactoryFunction · 0.70

Calls 2

addFunction · 0.70
toTypeFunction · 0.70

Tested by

no test coverage detected