Keep original url for pushstate

Keep original url for pushstate

I use the following function:

$( document ).ajaxComplete(function() { var currenturl = window.location.href; var decodedUri = decodeURIComponent(currenturl); var decodedUri2 =decodedUri.replace("&manufacturer[]=","/").replace("&page=","/").replace("&sort=","/").replace("&order=","/"); history.pushState("", "", decodedUri2); });

I need somehow at each ajax completion to change original url and not previously changed url through pushState.

With the function above at first ajax completion pushState does the job but on next ajax completion pushState decodedUri2 tries to replace from changed url but i need every time to change the original url and pushState the result. Is that possible?

Any ideas of achieving this?

EXAMPLEhttp://ocdemo.eu/desktops.

If you select filters from left column each time url is changing with ajax. So each time i need the shown url to be replaced with something else