Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make a popup chat application without using ajax

I have made a dating website where I have use one to one chatting application like facebook. When one user send any message to another user it showing into their popup chat box, but I have done this using ajax. Which I have run in every interval using javascript setInterval function. But I think the process is not optimize one. I don't want to make unnecessary request to the server each time, rather it only trigger when there is some new message for that user. Is there any other way to do it or any other protocol which using by big site like facebook, gmail?

like image 284
Amar Banerjee Avatar asked Dec 13 '25 08:12

Amar Banerjee


1 Answers

You could do this using WebSockets, but that requires both a server implementation and a web browser that supports it.

Another technique is to use Long Polling, but again, this requires work on both the client and the server. The advantage is that this is a cross browser compatible technique.

like image 144
Josh Avatar answered Dec 14 '25 22:12

Josh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!