jquery's Serialize () method creates a URL-encoded text string by serializing the form value, we can select one or more form elements, or you can directly select the form to serialize it, such as:
<FormAction="">First Name:<InputType= "text" Name= " FirstName " Value=" Bill. /><br />< Span style= "color: #000000;" >last Name: <input = "text" Name= " LastName " Value/><br />< Span style= "color: #0000ff;" ></form>
$ (document). Ready (function() { // firstname=bill&lastname=gates});
In this way, we can pass the serialized value to Ajax () as the URL parameter, and easily use Ajax () to submit the form form, instead of one to get the value of the form and then passed to Ajax (), for example, as follows:
$.ajax ({ type: ' Post ', url: ' Your URL ', data: $ ("form"). Serialize (), function // Your Code }});
The same is true with $.post (), $.get (), and $.getjson ():
function(data) { // Your code function// Your codefunction// Your code }});
JQuery Ajax () submits form data using serialize ()