Chrome displays ajax response when pressing back button

后端 未结 8 2059
闹比i
闹比i 2020-12-07 22:05

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 sh

相关标签:
8条回答
  • 2020-12-07 23:08

    The @abraham's answer is right. I just wanted to post a solution for Rails: all you need is just add different path to routes.rb.

    In example, I have resource :people and I want to compose index page from ajax parts one of those is list of people. The straightforward way is to create index.js.erb and to load partial via ajax using url: people_path. But here occurs the issue.

    So, for Rails, it needs just add a different route, like

    get 'people_list', to: 'people#index', as: :people_list, format: :js

    0 讨论(0)
  • 2020-12-07 23:09

    Just add the following header to the Response headers :

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