Skip to content

Instantly share code, notes, and snippets.

@shubham7298
Created August 29, 2018 04:56
Show Gist options
  • Save shubham7298/49b63f2f9491c8a7967c05d1b7219fc4 to your computer and use it in GitHub Desktop.
Save shubham7298/49b63f2f9491c8a7967c05d1b7219fc4 to your computer and use it in GitHub Desktop.
Generating Query Params
var params = {
a : any.value,
b : other.value
}; // Add any no. of parameters you want to pass separated using "."
function paramsChange(params){
var queryString = $.param(params);
var queryString = Object.keys(params).map((key) => {
return encodeURIComponent(key) + '=' + encodeURIComponent(params[key])
}).join('&');
console.log(queryString);
updateURL();
function updateURL(){
if (history.pushState) {
var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?' +queryString;
window.history.pushState({path:newurl},'',newurl);
}
}
window.location.reload();
// params changed
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment