ajax serialize() method
Translation results:
serialize
UK [ˈsɪəriəlaɪz] US [ˈsɪriəlaɪz]
vt. Serialization, serialization (story)
ajax serialize() methodsyntax
Function: The serialize() method creates a URL-encoded text string by serializing form values. You can select one or more form elements (such as inputs and/or text boxes), or the form element itself. Serialized values can be used in URL query strings when making AJAX requests.
Syntax: $(selector).serialize()
Description: The .serialize() method creates text characters represented in standard URL encoding string. It operates on a jQuery object that represents a collection of form elements.
ajax serialize() methodexample
<html> <head> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("div").text($("form").serialize()); }); }); </script> </head> <body> <form action=""> First name: <input type="text" name="FirstName" value="Bill" /><br /> Last name: <input type="text" name="LastName" value="Gates" /><br /> </form> <button>序列化表单值</button> <div></div> </body> </html>
Click the "Run instance" button to view the online instance