Home  >  Article  >  Web Front-end  >  jquery method to serialize a form into an object_jquery

jquery method to serialize a form into an object_jquery

WBOY
WBOYOriginal
2016-05-16 17:05:39751browse
Copy code The code is as follows:

var aa=function(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;
}

Just pass a form object in. After method processing, you can return an object. For example, console.info(aa($( "#myForm"))); You can try this in Firefox browser. It's a very good method.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn