依赖于jquery将表单元素序列化为json格式,实现代码如下:
//定义serializeObject方法,序列化表单
$.fn.serializeObject = function() {
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name]) {
if (!o[this.name].push) {
o[this.name] = [ o[this.name] ];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
使用:
var params = $('form').serializeObject();
序列化后的结果:
{
"receiverIds": "WUHUI",
"receiverNames": "吴辉",
"msgTitle": "回复:是的",
"typeTag": "02",
"msgContents": "<p>阿斯蒂芬</p>",
"parentId": "6d959fc6f5ce4d2b86ccde71bee570ac"
}
参考:
最新评论
azgkf或777
磁力链接不对。下面这个链接才是的 magnet:?xt=urn:btih:73F98BFF1E8C4EE83A962FCF715D0A3120E1BB63
文件违规,根据相关法律法规要求,该文件已禁止访问
oppo手机,没有Didn't get the code按钮