Vyshnavi Samudrala Vyshnavi Samudrala - 5 months ago 11
Ajax Question

Modify specific parameter value in the URL without reloading the page

I have a URL


In this URL, I just need to update the
in the URL on selecting the distance option without reloading the page.

<select name="sort_val" class="sort_select">
<option value="sort_distance">Sort by Distance</option>
<option value="sort_price">Sort by Price</option>
<option value="sort_ratings">Sort by Ratings</option>


Hi you can use below solution, I hope it will helps to you.

    var queries = {};
    $.each(document.location.search.substr(1).split('&'), function(c,q){
        var i = q.split('=');
        queries[i[0].toString()] = unescape(i[1].toString()); // change escaped characters in actual format
     history.pushState({}, '', "?"+$.param(queries));

Thanks :)