Home > Web Front-end > JS Tutorial > Detailed explanation of examples of serialize() serialization function in jquery

Detailed explanation of examples of serialize() serialization function in jquery

黄舟
Release: 2017-09-07 14:05:56
Original
2074 people have browsed it

jquery series tutorial 6-AJAX full solution

serialize() serialization function in jquery

serialize() serialization, convert elements into xx=xx&xx=xx&xx= xx string form can not only be used in forms.

The code is as follows:

$(":checkbox,:radio").serialize();          //只会将选中的值序列化//serializeArray序列化dom元素,返回JSON格式数据
var fields = $(":checkbox,:radio").serializeArray();
$.each(fields,function(i,field){
    field.key;   //JSON的key
    field.value;   //JSON的值});//$.param()方法,序列化数组或映射
var obj={a:1,b:2,c:3};
var k= $.param(obj);                       //转化为a=1&b=2&c=3
Copy after login

The above is the detailed content of Detailed explanation of examples of serialize() serialization function in jquery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template