I am trying to make a very simple 2-local chat for my Django site. I am learning AJAX for this. I need parts of the web page to refresh without user interaction:
- When User 1 sends a message, it should appear on the User 2 screen.
- When user 1 logs out, his status should change to "offline" on the screen of User 2.
What is the easiest way to implement this? Do I need to use JavaScript to regularly poll the server? If so, what is the best practice for this? I found several solutions about using setInterval or setTimeout, but was not sure if this is the best way.
(I read the reverse of AJAX, but from what I read, it's harder to implement. I don't need my solution to be fast or scalable, I just need to work it.)
Rexe source share