我需要一个数据库更新时彗星刷新 html 的示例!
大家,
我正在开发一个网页,每次数据库更新时都需要刷新。我已经在我的 PHP 代码中完成了 checkDatabaseUpdate() 。
但现在我确实需要一些帮助来开发一个简单的彗星来等待响应,另一个来检查更新。
有没有人有任何简单的例子来帮助我?
comet 是正确的解决方案吗?
谢谢,
People,
I am developing a web page that need to be refresh everytime that the data base gets an update. I already have the checkDatabaseUpdate() done in my PHP code.
But now I reaaly need some help to develop a simple comet to wait for a response, and another to check for update.
Is there anybody with any simple example to help me?
Is comet the right solution for that?
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您想说的是,数据库在后端执行查询(INSERT、UPDATE、DELETE),并且您希望在执行该查询时刷新用户的首页?
嗯..使用 jQuery(循环)来“Ajax 检查”前端控制器中的数据库更新,然后刷新。
我现在想不出任何东西,但我想只需稍加修改,你就可以做到这一点。 twitter.com 就是这样做的。
What you want to say is that on the database are executed querys (INSERT, UPDATE, DELETE) in the backend and you want to refresh the front page of a user when that query`s are executed ?
Hmm .. use a jQuery (looping) to "Ajax check" for database update in the frontcontroller and then refresh.
I can't think of anything right now but i guess with little modification you shoul do the trick. This is how twitter.com do it.
由于 PHP 的工作方式(让 Web 服务器守护进程处理传入请求),将其与长轮询技术相结合可能会导致服务器不满意。每个连接的用户都将保持与 Web 服务器守护程序的连接。根据该守护程序的配置,您可能会发现 comet 是针对您自己的服务器的有效拒绝服务攻击。
您可能会更好地使用简单的旧的短暂的 ajax 轮询。
Because of the way that PHP works (having a web server daemon process incoming requests), combining it with long-polling techniques can make for an unhappy server. Each connected user is going to hold open a connection to the web server daemon. Depending on that daemon's configuration, you may find that comet is an effective denial of service attack against your own server.
You'd probably be better off with plain old short-lived ajax polling here.