jquer表单序列化加强版

Posted JGG靖哥哥

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jquer表单序列化加强版相关的知识,希望对你有一定的参考价值。

相同name值会转化为一个数组

$.fn.serializeObject = function(){
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
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;
};

jquery的序列化表单只能序列化成一个对象 , 但是接口接收的Array咋办呢? 请粘贴上面代码

以上是关于jquer表单序列化加强版的主要内容,如果未能解决你的问题,请参考以下文章