- form表单序列化传参
1.1 在url之后拼接字符串
var paramer = searchform.serializeArray(); var _formData={}; if($(paramer).length>=1){ var data = ""; for(var m=0;m<$(paramer).length;m++){ data += "&"+paramer[m].name+"="+paramer[m].value; } }
2.2 对象传参
var paramer = searchform.serializeArray(),searchData = {}; var _formData={}; if($(paramer).length>=1){ for(var m=0;m<$(paramer).length;m++){ var tmpstack={}; if(_formData[paramer[m].name]){ _formData[paramer[m].name]+=(","+paramer[m].value); }else{ tmpstack[paramer[m].name]=paramer[m].value; $.extend(_formData,tmpstack); } } }
时间: 2024-10-27 07:31:16