Javascript的自动更新页面? [英] Javascript auto update page?

查看:147
本文介绍了Javascript的自动更新页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以给我一个方向,我想知道怎么做,如Facebook自动更新的网页有新的状态更新,新的喜好等即,如果你有这样一个状态的一个窗口,用户点击打开 +1像自动出现。

Can anybody give me a direction, I want to know how to do auto updating pages like facebook have for new status updates, new likes etc. Ie., if you have a status open in a window and a user click "like", the +1 like automatically appears.

在此先感谢。

推荐答案

这些正在使用推模型(订阅/发布)。完成

These are done using a PUSH model (subscribe / publish).

客户端第一次预订发出一个AJAX请求。这AJAX请求保持活着下去。当服务器接收到一个新的像/评论,它发布了此更新的客户端,从而结束了AJAX请求。客户端接收此更新并isntantly发出另一个AJAX请求。

The client side first subscribes by issuing an AJAX request. This AJAX request stays alive indefinitely. When the server receives a new like / comment, it publishes this update to the client side thereby ending the AJAX request. The client receives this update and isntantly issues another AJAX request.

据大致分类彗星

在之前,我已经实现了一个彗星网络聊天应用程序,并写了什么地方进去一个有些技术性的写了起来。你可以在这里,如果有兴趣阅读。

Once before, I had implemented a Comet web chat application and wrote a somewhat technical write up of what went into it. You can read it here, if interested.

彗星网络聊天应用程序

Comet Web Chat Application

编辑:

一个心跳机制(拉模型)肯定是更容易实现,但推模式更为高效。

A heartbeat mechanism (PULL model) is definitely easier to implement, but a PUSH model is far more efficient.

这篇关于Javascript的自动更新页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆