Method of converting jQuery implementation object into url parameter

  • 2021-07-10 18:16:23
  • OfStack

In this paper, an example is given to describe the method of converting jQuery implementation objects into url parameters. Share it for your reference, as follows:

ajax Mode Object Parameters

var conditions = {status:0,title:'',specialId:'',creatorId:'',authorId:'',startViewCount:0,endViewCount:0,startFactTime:'',endFactTime:''};

Convert jQuery Object to url Parameter

// Export all query results 
function exportExcel(btnFlag) {
  // Query condition verification 
  var str = parseParam(conditions);
  var url = "/wamei/articleStatisticsController/export/excel.htm?"+str;
// Converts an object to url  Parameter 
var parseParam=function(param, key){
  var paramStr="";
  if(param instanceof String||param instanceof Number||param instanceof Boolean){
      var k=key==null?i:key+(param instanceof Array?"["+i+"]":"."+i);
      paramStr+='&'+parseParam(this, k);
  return paramStr.substr(1);

For more information about jQuery, please see the topics on 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 jQuery Common Plugins and Usage"

I hope this article is helpful to everyone's jQuery programming.

Related articles: