This example describes the jquery serialization method. Share to everyone for your reference. The specific analysis is as follows:
When you do Ajax, you often need to serialize,
Serialize () can only serialize the form. (Note: The contents of the form can only be used with name)
Now there is an object:
Copy Code code as follows:
var obj={a:1,b:2,c:3};
How do we get it serialized?
Prototype can be done with $h (obj). toquerystring ()? Is there any way jqueyr?
The answer is yes, jquery provides the $.param ().
var obj={a:1,b:2,c:3};
var k = $.param (obj);
Alert (k)/Output a=1&b=2&c=3
OK, let's try it. ^_^.
Examples of serialize serialization.
1. jquery Selector Select all input in the form (type is text and radio)
2. Serialize () to serialize it
var msg = $ ("#innerbox Input[type=text], #innerbox Input[type=radio]"). Serialize ();
$.ajax ({
type: "POST",
URL: "add.php",
data:msg,
success:function (data) {$ (". ShowMsg"). HTML ( data); }
});
I hope this article will help you with your jquery programming.