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咋办呢? 请粘贴上面代码

原文地址:https://www.cnblogs.com/sunjinggege/p/8085266.html