简体   繁体   English

如何避免在Rails4中不修改304,ajax无法正常工作

[英]How to avoid 304 not modified in rails4, ajax not working

I'm a beginner in rails and making a simple application with it. 我是Rails的初学者,并使用它进行了简单的应用程序。 But every time I refresh or reload a page, it returns 304 not modified status, and ajax doesn't work at all! 但是,每次刷新或重新加载页面时,它都会返回304未修改状态,而ajax根本不起作用! It really bothers a lot. 真的很困扰。 I have set config.action_controller.perform_caching = false and added $.ajaxSetup({cache: false}); 我已经设置config.action_controller.perform_caching = false并添加了$.ajaxSetup({cache: false}); and even Cache-Control:no-cache to the application.js. 甚至Cache-Control:no-cache到application.js。
It just can't work. 就是行不通。
Is there any effective way to make ajax working? 有什么有效的方法可以使Ajax工作吗?

Remove Turbolinks from your project. 从您的项目中删除Turbolinks。 You need to do couple of steps: 您需要执行几个步骤:

  • remove turbolinks gem from Gemfile 除去turbolinks从宝石的Gemfile
  • remove requires from application.js and application.css 从application.js和application.css中删除需求
  • remove data-turbolinks-track from you application layout file 从应用程序布局文件中删除data-turbolinks-track

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM