Moving back to a pushState entry that used ajax

后端 未结 1 2003
南笙
南笙 2021-02-01 07:23

I\'m having an issue with the following situation.

  1. User visits site
  2. User clicks link which uses history.pushState to update the url
  3. Partial page
相关标签:
1条回答
  • 2021-02-01 08:09

    It seems that some browsers often confuse the partial loaded via ajax and the entire page, decorated with its layout. That's because they both have the same URL. So when the user click on the back button, the browser won't load the URL and will just display the partial it has previously downloaded via ajax.

    To avoid this and maintain two separate internal caches (one for the partial page and one for the entire page), you should add a GET parameter in the URL when calling via ajax. Like this in your code:

    popstate = function(url){
      $('#content').load(url+'?_ajax=1');
    }
    

    Hope this helps.

    0 讨论(0)
提交回复
热议问题