1 serializeObject = function (form) { /*将form 表单元素的值序列化*/ 2 var obj = {}; 3 $.each(form.serializeArray(), function (index) { 4 if (obj[this['name']]) { 5 obj[this['name']] = obj[this['name']] + "," + this['value']; 6 } else { 7 obj[this['name']] = this['name']; 8 } 9 }); 10 };
//使用方法 serializeObject("这里传form元素对象");