I am sending an AJAX request like this:

$(document).ready(function(){ $('#blog_url').click(function(){ $.ajax({ url: "blog.php", cache: false, success: function(html){ $(".row").html(html); window.location.hash = 'blog.php'; } }); }); 

Changing the URL is but the link becomes site.ru/blob.php#blog.php

Tell site.ru/blog.php how to make the link become site.ru/blog.php ?

  • one
    return false? - Vfvtnjd
  • I will add: Ciner, the link in the form of site.ru/blog.php you will not get with the help of location.hash, because location.hash is responsible for the hash (sorry for French), which is anchor . - Vfvtnjd

5 answers 5

so or

 window.location.href = "http://"+window.location.domain+"/blog.php"; 

    No, why not search in the net of information already just a sea!

     window.history.replaceState(“object or string”, “Title”, “/another-new-url”); 
    • one
      I’ll add that I’ve broken down the vehicle)) HTML5-History-API , on the bottom of the page, is a manual in Russian. There are also useful links and demos. - Deonis
    • in the in. so I did not post links. - Artem

    http://javascript.ru/window-location

    Read, there is some

      event.preventDefault() , so that the click itself does not work, maybe it will help?

       $(document).ready(function(){ $('#blog_url').click(function(e){ e.preventDefault(); $.ajax({ url: "blog.php", cache: false, success: function(html){ $(".row").html(html); window.location.hash = 'blog.php'; } }); }); }); 

        A similar answer was already given on HashCode:

        A line that will change the world

        Habr:

        Introduction to HTML5 History API

        As always, in browsers that have already smelled mothballs, in particular in IE6, all this "joy" does not work. In the latter, the link can be made through the hash "#!" (SEO hash).

        There are many libraries that greatly simplify working with a url.

        • pjax - does not work with hashes (principal position of the author);
        • address - works with hashes;
        • history.js .

        Key queries for search: "replaceState" and "pushState" .