Home >Web Front-end >JS Tutorial >Example analysis of serialize() usage in JQuery_jquery
The example in this article describes the usage of serialize() in JQuery. Share it with everyone for your reference. The specific analysis is as follows:
1. Definition and usage of serialize():
Theserialize() method creates a standard URL-encoded text string by serializing form values. Its operation object is a jQuery object representing a collection of form elements. You can select one or more form elements (such as inputs or text fields), or the form element itself. Serialized values can be used in URL query strings when making AJAX requests.
Syntax:
$(selector).serialize()
Detailed description
1. The .serialize() method creates a text string represented by standard URL encoding. It operates on a jQuery object that represents a collection of form elements.
2. The .serialize() method can operate jQuery objects that have selected individual form elements, such as ,
3. Only "successful controls" will be serialized into strings. If you do not use a button to submit the form, the submit button's value is not serialized. If you want a form element's value to be included in a sequence string, the element must use a name attribute.
4. The name in the form cannot use keywords in Js and jquery.
For example: length
//Use:$("#form1").serialize();
The value above cannot be obtained.
2. Example of serialize() in JQuery
1. ajax serialize()
2. serialize() serialize form instance