get server response without using setinterval for chat applicaton php jquery

冷暖自知 提交于 2019-12-06 05:44:25

问题


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..


回答1:


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 ...



来源:https://stackoverflow.com/questions/7202978/get-server-response-without-using-setinterval-for-chat-applicaton-php-jquery

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!