Django chat with ajax polling

≡放荡痞女 提交于 2021-02-05 20:38:32

问题


I need to create a chat similar to facebook chat.

I am thinking to create a simple application Chat and then using ajax polling ( to send request every 2-3 seconds ).

Is this a good approach ?


回答1:


I'd go with something that involves push/real-time messaging controlled by the server. You'll get proper real-time chat and it will scale a lot better. Take a look at http://www.orbited.org/ which is the way to go, I reckon. It's not core django, but it's Python and will sit well alongside a Django app on your server




回答2:


ajax is the best here

what you will need: 1) server view that will return recent messages 2) client-side caller by timer (I prefer jQuery and its timers plugin) and success handler, that will populate the chat window



来源:https://stackoverflow.com/questions/2973591/django-chat-with-ajax-polling

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