function ArrayToString(arr,str) { /* 函数功能:数组根据分割字符(串)转换为字符串 参数: arr:需转换的字符串数组 str:分割字符串 返回值: 转换后的字符串 */ var strTmp = ""; for(var i=0;i<arr.length;i++) { if(arr[i]!="") { if(strTmp=="") { strTmp = arr[i]; } else { strTmp = strTmp + str + arr[i]; } } } return strTmp; } /* * javascript复杂对象转url参数字符串 */ var parseParam=function(param, key){ var paramStr=""; if(param instanceof String||param instanceof Number||param instanceof Boolean){ paramStr+="&"+key+"="+encodeURIComponent(param); }else{ $.each(param,function(i){ var k=key==null?i:key+(param instanceof Array?"["+i+"]":"."+i); paramStr+='&'+parseParam(this, k); }); } return paramStr.substr(1); }; //调用: var obj={name:'tom','class':{className:'class1'},classMates:[{name:'lily'}]}; parseParam(obj); 结果:"name=tom&class.className=class1&classMates[0].name=lily" parseParam(obj,'stu'); 结果:"stu.name=tom&stu.class.className=class1&stu.classMates[0].name=lily"