What you are looking for is something which is (now) quite common, and is sometimes called "real-time web". It's the ability to have your server-side code push content to the connected clients as it happens, in real-time.
This is possible through a couple of new mechanisms which are supported by newest browsers (and servers), and by some other mechanisms which weren't really designed to do that, but which can be used as "hacks" to make it work.
The first thing you have to understand is that what you are asking for (a server "pushing" a message to a client) is not how the web (or, at least, http) is (or better, was) intended to work.
The classic web is stateless, request-response, half-duplex: the client initiates the communication, opens a connection to the server, the server serve something, and the connection is closed.
And there used to be no way for a server to send a message to a web client: the client (i.e. your browser) should support the reverse model (offering an endpoint on which it listens), becoming effectively a server.
This is, more or less, what newer standards like WebSockets offer (another standard worth mentioning is Server-sent events (SSE); however, its support is even scarcer than WebSockets, and they seem more apt to "stream" content than sending single messages).
Unlike HTTP, WebSocket provides full-duplex communication (either party can initiate it), which is what you are looking for.
The correct version of the WebSocket protocol (an older, buggy implementation exist in some browsers) is implemented in Firefox 6, Safari 6, Google Chrome 14, Opera 12.10 and Internet Explorer 10.
So, what if your browser does not support WebSockets? You have to use those "tricks" I mentioned earlier. Those "trick" fall under the unbrella of Push technologies.
In particular, a common technique is long polling.
Like the name says, it is not "push"; long polling is polling, i.e. a "pull" technique, but it allows to emulate a push mechanism.
With long polling, the client requests information from the server exactly as in a normal AJAX call, except it issues its HTTP/S requests (polls) at a much slower frequency.
Upon connection, the server (your server, your API: a servlet, an HTTP handler, a REST controller, whatever! It is usually the same mechanism with which you provide support for your standard AJAX calls) sends some info if there is already an update already available; if there is nothing new, instead of sending an empty response, it holds the request open and waits for response information to become available.
You have a "traditional" client-initiated request, but that is put "on hold" until there is something that the server wants to communicate to you.
Once there is something, the server sends a response (via the HTTP channel, still open!) to the client, completing the open HTTP Request.
Other techniques (like using sockets provided by plugins - Silverlight, Java applets, Flash..) can be used, but then again for exploiting them you need the correct client (brower/plugin combo).
Of course, you could implement all this stuff by yourself. And I encourage you to try as a learning exercise.
For your production code, you better use a library that encapsulates all these concepts and techniques, like SignalR (for ASP.NET) Ratchet (for PHP), Signal.IO (for node.js), Faye (for Ruby).... Some of these libraries will implement more than one technique, choose the best technique based on the client, falling back to other ones automatically. They really spare you a lot of trouble!