应用程序范围的事件监听器? [英] Application-wide Event Listener?
问题描述
我有一个页面通过ajax(json)更新表的数据.它每分钟检查一次新数据,因此该页面不必进行完整的回发.我认为这是很多不必要的网络流量.是否有可能从(单独的)数据输出页面监听的数据输入页面引发事件?
我知道HTTP是无状态的,有没有办法设置像可以触发的JavaScript侦听器那样的方式?不需要定期检查数据更改的东西,可以被动地通知数据更改的东西吗?
也许我应该花一些时间查看gmail的javascript和/或HTTP请求.如何通知Gmail显示新的收件箱电子邮件?
在此先感谢您的任何想法.
I have a page updating a table''s data through ajax(json). It checks for new data every minute, so the page doesn''t have to do a full postback. I think this is a lot of unnecessary network traffic. Is it possible to have an event raised from the data entry page that is listened to by the (separate) data output page?
I know HTTP is stateless and all that, is there a way to set up, like, a javascript listener that could be triggered? Something that doesn''t have to check for data changes periodically, something that can be notified of a change in the data passively?
Maybe I should spend some time looking at gmail''s javascript and/or HTTP requests. How does Gmail get notified to display a new inbox email?
Thanks in advance for any thoughts on this.
推荐答案
Gmail会不断进行AJAX调用.出于您所说的原因,这就是它的全部工作.
Gmail makes constant AJAX calls. That''s about all it can do, for the reasons you''ve stated.
这篇关于应用程序范围的事件监听器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!