Chrome displays ajax response when pressing back b

2019-01-16 15:58发布

I've come across a problem that if I use jQuery's Get method to get some content, if I click back, instead of it actually going back one page in the history, it instead shows the content returned by the Ajax query.

Any idea's?

http://www.dameallans.co.uk/preview/allanian-society/news/56/Allanian-test

On the above page, if you use the pagination below the list of comments you will notice when clicking back after changing a page, that it shows the HTML content used to generate the list of comments.

I've noticed it doesn't always do it, but if you click on a different page a few times and click the back button, it simply displays json text within the window instead of the website.

For some reason, this is only affecting Chrome as IE and Firefox work ok.

7条回答
霸刀☆藐视天下
2楼-- · 2019-01-16 16:33

Just add the following header to the Response headers :

Vary: Accept
查看更多
登录 后发表回答