如何用JS实现对象转为url参数,具体如下:
ajax 方式对象参数。代码如下:
var conditions = {status:0,title:'',specialId:'',creatorId:'',authorId:'',startViewCount:0,endViewCount:0,startFactTime:'',endFactTime:''};
jQuery 对象转为url参数
//导出全部查询结果 function exportExcel(btnFlag) { //查询条件验证 searchCheck(btnFlag); var str = parseParam(conditions); var url = "/wamei/articleStatisticsController/export/excel.htm?"+str; window.location.href=url; } //将对象转成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); };
网友评论文明上网理性发言 已有0人参与
发表评论: