The method of converting an element in a form into an object is suitable for form submission

  • 2020-03-30 02:49:46
  • OfStack

 
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; 
} 


Related articles: