开发者

Realitme via ajax, How to create an open connection to a non-blocking server like tornado etc?

When people create real-time web apps, they are le开发者_运维技巧aving a ajax request open/long running.

how do they do this in javascript?


There is really no difference from a normal ajax request. A callback is associated with the XMLHttpRequest. Once the request is complete the callback is invoked. The difference is on the server-side where the request is held open until data is ready for the client, or a timeout occurs. On the browser side, the callback is invoked as each successive request is answered. The callback must process the data from the server and initiate another request. The request is handled asynchronously, so the browser is not blocked.

A really good example of the whole thing is the chat demo included in Tornado.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜