This article describes the method of converting objects into url parameters by jQuery. Share it for your reference, as follows:
ajax method object parameters
Copy the codeThe code is as follows:
var conditions = {status:0,title:'',specialId:'',creatorId:'',authorId:'',startViewCount:0,endViewCount:0,startFactTime:'',endFactTime:''};
Convert jQuery object to url parameter
//Export all query resultsfunction exportExcel(btnFlag) { //Query condition verification searchCheck(btnFlag); var str = parseParam(conditions); var url = "/wamei/articleStatisticsController/export/?"+str; =url; } //Convert the object to url parametersvar 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 (1); };
For more information about jQuery, please view the special topic of this site: "Summary of jQuery string operation skills》、《Summary of jQuery operation xml skills》、《Summary of jQuery extension skills》、《Summary of jquery selector usage"and"Summary of commonly used plug-ins and usages of jQuery》
I hope this article will be helpful to everyone's jQuery programming.