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

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

黄舟
黄舟Original
2017-09-07 14:05:562034browse

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

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!

Statement:
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