表单序列化 js

时间:2023-03-08 18:41:39

function serliaze(form) { //序列化表单
var obj = {};
$.each(form.serializeArray(), function (index) {
if (obj[this['name']]) {
obj[this['name']] = obj[this['name']] + ',' + this['value'];
} else {
obj[this['name']] = this['value'];
}
});
return obj;
}