如何使一个弹出的聊天应用程序,而无需使用AJAX [英] how to make a popup chat application without using ajax

查看:78
本文介绍了如何使一个弹出的聊天应用程序,而无需使用AJAX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经做了一个交友网站,我必须用一个像Facebook 1聊天应用。当一个用户发送任何信息给其他用户也将展示其弹出的聊天框,但我已经做到了这一点用ajax。这是我使用javascript setInterval函数运行在每一个区间。但我认为这个过程是不是最佳的。我不想作无谓的请求到服务器每一次,而是只有触发时,有该用户的一些新的信息。有没有做任何其他方式或通过大网站如Facebook,Gmail中使用的任何其他协议?

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?

推荐答案

您可以做到这一点使用的WebSockets ,但同时需要服务器执行和支持它Web浏览器。

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.

这篇关于如何使一个弹出的聊天应用程序,而无需使用AJAX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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