Home >Web Front-end >JS Tutorial >jquery serialization method example analysis_jquery
The examples in this article describe the jquery serialization method. Share it with everyone for your reference. The specific analysis is as follows:
When doing ajax, serialization is often needed,
serialize() can only serialize forms. (Note: Only name can be used for the content in the form)
There is now an object:
How to serialize it?
Can it be done with $H(obj).toQueryString() using prototype? Is there any method in jqueyr?
The answer is yes, jquery provides $.param().
var obj={a:1,b:2,c:3}; var k = $.param(obj); alert(k) // 输出 a=1&b=2&c=3
Okay, let’s try it. . ^_^.
Example of serialize serialization. .
1. jquery selector selects all inputs 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 be helpful to everyone’s jQuery programming.