jquery form 表单 json 序列化方法
form 表单 json 序列化方法
// 表单json序列化 a 参数 $('#form').serializeArray()
window.serializeObject = function (a) {
var o = {};
$.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;
};