Online chat solutions have been very popular long before AJAX was born. There are numerous reasons for this popularity, and you’re probably familiar with them if you’ve ever used an Internet Relay Chat (IRC) client, or an Instant Messenger (IM) program, or a Java chat applet. AJAX has pushed online chat solutions forward by making it easy to implement features that are causing trouble or are harder to implement with other technologies. First of all, an AJAX chat application inherits all the typical AJAX benefits, such as integration with existing browser features, and (if written well) cross-platform compatibility.

An additional advantage is that an AJAX chat application avoids the connectivity problems that are common with other technologies, because many firewalls block the communication ports they use. On the other hand, AJAX uses exclusively HTTP for communicating with the server.

Probably the most impressive AJAX chat application available today is Meebo (http://www.meebo.com). We are pretty sure that some of you have heard about it, and if you haven’t, we recommend you have a look at it. The first and the most important feature in Meebo is that it allows you to log in into your favorite IM system by using only a web interface. At the time of writing, Meebo lets you connect to AIM or ICQ, Yahoo! Messenger, Jabber, or GTalk, and MSN. You can access all these services from a single web page with a user friendly interface, with no pop-up windows or Java applets.

Meebo isn’t the only web application that offers chat functionality. Even if AJAX is very young, a quick Google search on “AJAX Chat” will reveal several other applications. It’s time to get to work. In the rest of the chapter, we’ll implement our own online chat application. We’ll use this occasion to learn about JSON (JavaScript Object Notation), which represents an alternative to XML for representing data exchanged between the web browser and the web server.

Download pdf AJAX and PHP Building Responsive Web Applications