Definition and usage
The Serializearray () method creates an array of objects (names and values) by serializing the form values.
You can select one or more form elements (such as input and/or textarea), or the form element itself.
Grammar
$ (selector). Serializearray ()
Detailed description
The Serializearray () method serializes the form element and returns the JSON data structure.
Note: This method returns a JSON object rather than a JSON string . You need to use a plug-in or a third-party library for string operations, such as:
var forminfo = $ (' #contextFrom '). Serializearray ();
FormInfo = $.tojson (forminfo).
The returned JSON object consists of an array of objects, each of which contains one or two name-value pairs of the--name parameter and the value parameter if value is not empty. For example:
[{name: ' FirstName ', Value: ' Hello '}, {name: ' LastName ', Value: ' World '}, {name: ' Alias '},//value is empty]
The. Serializearray () method uses the standard of the successful controls (active control) to detect which elements should be included. Specifically, the element cannot be disabled (disabled elements are not included), and the element should have a name attribute. The value of the Submit button is also not serialized. The data for the file selection element is also not serialized.
JQuery Ajax-serializearray () method