Today, I found a serialize method in jquery while reading the source code. I have carefully studied it. Now I want to write it out and consolidate it.
In our normal form submission, we often need to extract a form one by one, which is difficult to use ajax in jquery. Therefore, with this function, we can use serialize () in jquery () serialization value of the method, which is convenient for us to process quickly and easily. Now let's take a look at what is serialize
First, create a simple test.html page on the side of my vimeditor:
<Html>
<Head>
<Title> Serilize </title>
<Script type = "text/javascript" src = "./jquery. js"> </script>
<Script type = "text/javascript">
Function s (){
Var input = $ ('input'). serialize (); // serialized Value
Alert (input );
}
</Script>
</Head>
<Body>
<Form method = "post" action = "" onSubmit = "s ()">
Name: <input type = "text" name = "name"/> <br>
Sex: <input type = "text" name = "sex"/> <br>
Phone: <input type = "text" name = "phone"/> <br>
Email: <input type = "text" name = "email"/> <br>
QQ: <input type = "text" name = "qq"/> <br>
<Input name = "submit" type = "submit" value = "CLICK"/>
</Form>
</Body>
</Html>
Now you paste the above Code into your editor and save the test and submit it. The following window will pop up:
Of course, you may be confused why the serialized value is garbled, which uses the json_encode (); function for translation !!
Now, let's write it here. If you don't understand it, Let's post it !!!
Author "You_Can"