在不使用setinterval进行聊天应用程序php jquery的情况下获取服务器响应 [英] get server response without using setinterval for chat applicaton php jquery

查看:69
本文介绍了在不使用setinterval进行聊天应用程序php jquery的情况下获取服务器响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个聊天应用程序,这是刷新代码

   setInterval(function() {
      $('#DisplauDiv').load('show-chat.php?session=<?php echo $_GET['session'];?>');

   }, 1000);

这会持续每秒加载,这会减慢Mysql的性能. 当我脸颊Facebook(萤火虫)时,他们没有这样的东西来获取服务器的响应.

请告诉我执行此操作的技术.

感谢所有人阅读和重播此内容.

解决方案

好吧setInterval是可怜的人,看看 COMET

也请参见此答案使用php的反向Ajax实现

另请参阅此链接如何实现Facebook聊天窗口?

打开firebug,在Facebook页面上打开firebug的网络面板,然后转到xhr,您会发现一个连续的纺车是COMET ...

i made a chat application, here is the refresh code

   setInterval(function() {
      $('#DisplauDiv').load('show-chat.php?session=<?php echo $_GET['session'];?>');

   }, 1000);

And this keep loading in each second, that will slow down the perfomance of my Mysql. While i cheeked Facebook(firebug), they dont have anything like this to get response from server.

Please tell me the technique to do this.

Thanks in advance to all for reading and replaying this..

解决方案

well setInterval is poor man's comit have a look at COMET

also see this answer Reverse Ajax implementation using php

also see this link How are the facebook chat windows implemented?

open firebug will you are on the facebook page open the net panel in firebug and go to xhr you will notice a continuous spinning wheel that is COMET ...

这篇关于在不使用setinterval进行聊天应用程序php jquery的情况下获取服务器响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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