$.ajaxMutiUpload提交表单中data传参的序列化问题

来源:互联网 发布:学vb必看书 编辑:程序博客网 时间:2024/05/21 19:28

页面中参数太多,但是用$("#moduleform").serialize()序列化之后不是json格式的,这时需要将参数重新排列成json格式传输:

//序列化参数         var params = serializeObject($("#moduleform").form());          $.ajaxMutiUpload({   type:"post",       url:url,       secureuri:true,// 安全提交,默认为false       data:params,       dataType:'json',       fileElementId:"phote",       success:function(result){        window.location.href = "${pageContext.request.contextPath}/systemObjectAction_list.action";$.messager.show({title:'友情提示', msg:result.message});}});
function serializeObject(form){var obj = {};$.each(form.serializeArray(),function(index,field){if(obj[this['name']]){obj[this['name']] = (obj[this['name']]) + "," + (this['value']);}else{obj[this['name']] = (this['value']);}});//默认ajax请求显示//obj['typeId'] = "1";return obj;};



0 0
原创粉丝点击