Vyshnavi Samudrala Vyshnavi Samudrala - 1 year ago 58
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>

Answer Source

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 :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download