Definition and usage
The serialize () method creates a URL-encoded text string by serializing the form value.
You can select one or more form elements (such as input and/or text boxes), or the form element itself.
The serialized value can be used in the URL query string when generating an AJAX request.
$ (selector). Serialize ()
Example:
<HTML><Head><Scripttype= "Text/javascript"src= "/jquery/jquery.js"></Script><Scripttype= "Text/javascript">$ (document). Ready (function(){ $("Button"). Click (function(){ $("Div"). Text ($ ("form"). Serialize ()); });});</Script></Head><Body><formAction=""><inputtype= "text"name= "text"value= "1"ID= "a" /><inputtype= "checkbox"name= "Check"value= "Checked"ID= "F" /><textareaname= "textarea" >4</textarea><Selectname= "Select"><optionvalue= "1">1</option><optionvalue= "2">2</option></Select>First name:<inputtype= "text"name= "FirstName"value= "Bill" /><BR/>Last Name:<inputtype= "text"name= "LastName"value= "Gates" /><BR/></form><Button>Serialization of form values</Button><Div></Div></Body></HTML>
Output Result:
JQuery ajax-serialize () method