Implementing AJAX Chat
We’ll keep the application simple, modular, and extensible. For this we won’t implement a login module, chat rooms, the online users list, etc. By keeping it simple we try to focus on what the goal of this chapter is—AJAX Chat. We will implement the basic chat functions: posting and retrieving messages without causing any page reloads. We’ll also let the user pick a color for her or his messages, because this involves an AJAX mechanism that will be another good exercise.
Starting from the following application that will be presented in this chapter, we can easily extend it by implementing any other modules that can be found in the solutions presented above and that are not presented here. Take this part as homework for those of you who are interested in it.
Note
In order to have these example working you need the GD library. The installation instructions in Appendix A include support for the GD library.
The chat application can be tested online at http://ajaxphp.packtpub...