Ajax自动更新视图
我偶然发现了 Polyvore 网站并尝试了一下。
当使用其“创建集合”功能之一时,该网站会显示您的项目或其他地方的项目的视图。假设我在同一浏览器中打开两个选项卡,其中一个选项卡显示项目列表。如果我使用另一个选项卡将新项目添加到我的收藏中,另一个选项卡将自动更新。仅当我在同一浏览器上使用选项卡时才会发生这种情况。如果我没记错的话,这种技术叫做“push ajax”?
谁能告诉我如何构建这样的东西?
I came across the site Polyvore and gave it a try.
When using one of its "Create a set" feature, the site shows u a view of your items or items from somewhere else. Let's say if I open two tabs in the same browser one of which showing the items list. If I use the other tab to add a new item to my collection, the other one will automatically be updated. This only happens when I use tabs on the same browser. If I'm not wrong this technique is something called "push ajax"?
Can anyone tell me how to build something like this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您要寻找的可能是彗星。当我们获得对网络套接字的广泛支持时,这项技术才会真正发挥作用,在那之前,它就像是使用长轮询等技术的黑客攻击。
然而,据我所知,您只是对本地计算机上的两个浏览器实例之间的通信感兴趣。如果是这种情况,那么您可能不需要在服务器上实现推送,您可以使用本地存储并对其进行快速轮询以查找更改。看看 https://stackoverflow.com/questions/1194784/which-browsers-支持-html5-离线存储
What you're looking for is probably comet. The technique is really going to come into its own when we get wide support for web sockets, until then it is kind of a hack using techniques like long polling.
However from what I can tell you're just interested in talking between two instances of a browser on a local computer. If that is the case then you might not need to go to the point of implementing push on the server you could use local storage and do rapid polling of it to look for changes. Take a look at https://stackoverflow.com/questions/1194784/which-browsers-support-html5-offline-storage
也许看看http://www.pubnub.com/,他们提供了ajax推送服务。
Maybe look at http://www.pubnub.com/, they offer a ajax push service.