I am refreshing my page using jQuery:
location.reload();
This is working great but I want to refresh the same page by passing a parameter to URL.
How can I do this by using jQuery?
Ex:
If my url is www.myweb.com, I want to refresh this by passing a parameter like this
www.myweb.com?single
Thank you
You should be able to accomplish this by using location.href
if(window.location.hostname == "www.myweb.com")
window.location.href += "?single";
You can use Javascript URLSearchParams.
var url = new URL(window.location.href);
url.searchParams.set('single','');
window.location.href = url.href;
[UPDATE]: If IE support is a need, check this thread:
SCRIPT5009: 'URLSearchParams' is undefined in IE 11
Thanks @john-m to talk about the IE support