【工作查漏补缺】jQuery ajax - serializeArray()

方法用途:

获取表单内的所有有name的所有数据框,在非表单提交需要挨个遍历组装数据的情况下很好用

ps:需要jQuery支持

var twoform = $("#editProductActivityForm").serializeArray();(//id为表单id)

var newmsg = {};
$.each(twoform, function() {
if (this.value) {
newmsg[this.name] = this.value;
}

console.log(newmsg);//以上代码生成json对象

 

posted @ 2019-04-29 09:35  平胸定天下  阅读(267)  评论(0编辑  收藏  举报