开发者

Dynamic Status Updating

What is needed to implement a feature that emulates Twitter and Facebook in allowing one to post status posts an开发者_JS百科d seeing responses to these posts coming in automatically?


The term you're looking for is called "Comet" and there are different ways of acheiving it, each with many implementations, frameworks and code tutorials. Googling for "Comet" and the software you plan on using will be a good start.

Edit:

A newer technology to perform this style of communication is "WebSocket". It causes an HTTP connection (say as made by an AJAX request) to behave less like an HTTP connection (where the client sends data to the server, and the server can only return data in response to the send) and more like a normal TCP connection (where both sides can send and receive data at any time).


I would use a combination of jQuery $.ajax command along with a JavaScript setTimeout() function to poll a database every X seconds. That way you wouldn't have to do a screen refresh.


For posterity's sake, new visitors to this question may want to look into the WebSocket API that was proposed as part of HTML5. It's got pretty solid browser support at this point, even going back to IE 10, so it should be safe enough to use in modern applications.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜