问题描述
我想实现像www.foursquare.com
I would like to implement a realtime dashboard like an index page of www.foursquare.com
我检查foursquare.com的索引页与Chrome的开发工具,并惊讶,他们不使用XHR至约得到这些信息。每5秒
I checked foursquare.com's index page with Chrome's developer tool and surprised that they don't use xhr to get those information approx. every 5 seconds.
使用Ajax轮询导致某些浏览器内存泄漏,使服务器忙。
Using ajax polling causes memory leak in some browsers and make a server busier.
有没有办法,我可以实现一个实时仪表板有效地使用PHP和jQuery(AJAX)?
Is there any way that I can implement a realtime dashboard efficiently with PHP and jQuery(AJAX)?
(也许,我需要一个额外的服务器像一个推送服务器?)|
(Perhaps I need an extra server something like a push server?) :|
推荐答案
Foursquare的网页加载30个项目( ID = recent29
, ID = recent28
,...),但只显示11一次。所以,你将有一个实时的感觉约90秒(在此之后,同样的物品重新出现)。
Foursquare's homepage loads 30 items (id=recent29
, id=recent28
, ...) but displays only 11 at once. So you will have a real-time feeling for about 90 seconds (after that, the same items reappear).
...
$('#recent'+toShow).slideDown(1000, move(i));
$('#recent'+i).slideUp(1000, move(i));
...
对于一些双向的客户端服务器通信,看看的WebSockets ,即使他们不普遍支持的是,他们最终成为一个标准。
For some bidirectional client server communication, take a look at websockets, even though they are not universally supported yet, they eventually become a standard.
WebSocket的API正在由W3C标准化,和WebSocket协议被标准化由IETF。
这篇关于我怎样才能实现一个实时仪表板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!