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.
You should research long polling and web sockets. These allow your clients to have updates pushed to them more effectively. You could poll the server every x seconds, but it would be wasteful of resources.
You might want to have a look at SignalR, an async signaling library for .NET which would be perfect for a chat-application:
Scott Hanselman has a good example on his blog:
©2020 All rights reserved.