将form表单中的元素转换成对象的方法适用表单提交

网络编程 发布日期:2024/10/9 浏览次数:1

正在浏览:将form表单中的元素转换成对象的方法适用表单提交

复制代码 代码如下:
function serializeObject(form){
var o ={};
$.each(form.serializeArray(),function(index){
if(o[this['name']]){
o[this['name']] = o[this['name']] +","+this['value'];
}else{
o[this['name']] = this['value'];
}
});
return o;
}