js拼接多个url参数

var url       = 'test.php?c=index';
var selData   = {'selname':'rose','stime':2019,'etime':2020,'adminid':8};
jumptoSearchUrl(selData, url);

//拼接搜索条件并跳转
function jumptoSearchUrl(data, url){
	for(var key in data){
		if(data[key]){
			url += '&'+key+'='+data[key];
		}
	}
	window.location.href=encodeURI(url);
}

生成的url:test.php?c=index&selname=rose&stime=2019&etime=2020&adminid=8

你可能感兴趣的:(JQ)