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

Function buildParams

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

Source from the content-addressed store, hash-verified

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