Serializes all forms and form elements (like the .serialize() method) but returns a JSON data structure for you to work with.
Note: The JSON structure returned is not a string. You must use a plugin or third-party library to "stringify".
Note: The JSON structure returned is not a string. You must use a plugin or third-party library to "stringify".
The returned JSON structure consists of an Array of Objects where each Object contains one or two keys:
name for the parameter name and value for the parameter value if set/not empty.Example:
[
{name: 'firstname', value: 'Hello'},
{name: 'lastname', value: 'World'},
{name: 'alias'}, // this one was empty
]
Note that
serializeArray() only works on form elements, using this method on another element will not work. Also, this method will not give any results on nested forms, which are illegal in HTML anyway.