自动刷新Rails 3中的页面 [英] Auto Refresh a page in Rails 3

查看:128
本文介绍了自动刷新Rails 3中的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Rails 3中定期自动刷新页面?

解决方案

< head> 的适用视图。这个页面在POST参数发送时不应该使用,只有GET参数。将 5 更改为以秒为单位的时间间隔,您希望页面刷新。

 < meta http-equiv =refreshcontent =5/> 

虽然这个方法可行,但我建议考虑使用AJAX来刷新所需的内容,而不仅仅是速度更快但对用户的冲击更小,并且对服务器的负载影响更小。



这不是Rails特有的,适用于任何网页。由于Rails是服务器端,并且服务器无法控制浏览器,所以Rails无法控制页面刷新。


How to periodically auto refresh page with paramaters in Rails 3?

解决方案

Place the following HTML within the <head> of the applicable views. This should not be used when the page had POST parameters sent, only GET parameters. Change the 5 to the interval, in seconds, you want the page to refresh at.

<meta http-equiv="refresh" content="5" />

Though this works, I'd recommend considering using AJAX to refresh only the needed content which will not only be faster but less jolting to the user and will have a lower impact on your server's load.

This is not specific to Rails and applies to any webpage. Since Rails is server-side, and the server cannot control the browser, Rails has no control over page refreshing.

这篇关于自动刷新Rails 3中的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆