I have a search facility, for example the URL would be something like:-
What I want to do is create a link, i.e.
<a id="test" href="#">Order ASC</a>
That would update the records on this page on click of the above link, therefore it would need to update the URL to &order=asc which would re-order the listing that is on this page.
At the moment I am doing it as follows:-
jQuery('#test').on('click', function(e) {
e.originalEvent.currentTarget.href = window.location.href +'?order=DESC';
});
This gets the current URL and adds the value after the URL. The problem is that it keeps addings ?order=DESC?order=DESC every time you click. Also it would be a problem if ?order=DESC was already in the URL.
Any help would be much appreciated!