When a user sends a message, an AJAX request will be made to your server and you'll probably save the posted message to a database. You can also have an ajax request made every X seconds that checks for any newly posted messages on the server, and if there are any, it shows them to the user.
Alternatively you can use a technology called Comet, through which your server can 'push' a response to the clients to notify them whenever a new message has been posted.