This article mainly introduces the usage of serialize () in JQuery. The example analyzes the functions, definitions, and related usage skills of the serialize () method, for more information about how to use serialize () in JQuery, see the following example. Share it with you for your reference. The specific analysis is as follows:
I. serialize () definition and usage:
The serialize () method creates a standard URL-encoded text string by serializing the form value. its operation object is a jQuery object representing the form element set. You can select one or more form elements (such as input or text box) or form elements. Serialized values can be used in URL query strings when an AJAX request is generated.
Syntax:
$ (Selector). serialize ()
Detailed description
1. the serialize () method creates a text string encoded with a standard URL. Its operation object is a jQuery object that represents the form element set.
2. the serialize () method can operate jQuery objects that have selected individual form elements, such,And. However, Select// Use: $ ("# form1"). serialize ();The value cannot be obtained. II. serialize () instance in JQuery 1. ajax serialize () The code is as follows:$. Ajax ({Type: "POST ",DataType: "json ",Url: ajaxCallBack,Data: $ ('# myForm'). serialize (), // ID of the form to be submittedSuccess: function (msg ){Alert (msg );}});2. serialize () serialized form instance The code is as follows: