问题
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