I have been trying to change a parameter of my URL without reloading the site, however, I am not 100% sure what's wrong with my code. What happens in the URL is removing all the parameters and replacing it for a simple string. i.e http://localhost:50754/Signup555
And I want to change from http://localhost:50754/Signup?A=1&B=2&C=3 to http://localhost:50754/Signup?A=1&B=2&C=6
function changeQueryString(searchString, documentTitle) {
documentTitle = typeof documentTitle !== 'Pid' ? documentTitle : document.title;
var urlSplit = (window.location.href).split("?");
var obj = {
Title: documentTitle,
Url: urlSplit[0] + searchString
};
history.pushState(obj, obj.Title, obj.Url);
}
<a onclick="changeQueryString('555', 'Pid')"> change it</a>
Thanks in advance.