ajax-polling

How to implement a chat room using Jquery/PHP?

泪湿孤枕 提交于 2019-11-27 10:30:26
I'm looking to implement a chat room using PHP/Javascript (Jquery) with both group chat and private chat features. The problem is how to continually update the interface in a natural way and possibly also how to show 'X is typing..' messages in private chat. The obvious way seems to be that every X seconds/milliseconds the javascript pings the server and fetches a list of new messages between the last ping and now. However, this can make the interface seem a bit unnatural, if suddenly the chat room is flooded with 5 messages. I would rather each message appear as it is typed. Is there a way

Server-Sent Events vs Polling

最后都变了- 提交于 2019-11-26 19:14:17
问题 Is there a big difference (in terms of performance, browser implementation availability, server load etc) between HTML5 SSEs and straight up Ajax polling? From the server side, it seems like an EventSource is just hitting the specified page every ~3 seconds or so (though I understand the timing is flexible). Granted, it's simpler to set up on the client side than setting up a timer and having it $.get every so often, but is there anything else? Does it send fewer headers, or do some other

How to implement a chat room using Jquery/PHP?

对着背影说爱祢 提交于 2019-11-26 15:13:49
问题 I'm looking to implement a chat room using PHP/Javascript (Jquery) with both group chat and private chat features. The problem is how to continually update the interface in a natural way and possibly also how to show 'X is typing..' messages in private chat. The obvious way seems to be that every X seconds/milliseconds the javascript pings the server and fetches a list of new messages between the last ping and now. However, this can make the interface seem a bit unnatural, if suddenly the