Here we are going to make a simple chat engine using little Jscript, AJAX and back-end PHP. At the end of the tutorial, you will be able to make a chat engine of your own. This example will also make you able to use AJAX in your various purposes. Please follow step by step to understand properly.
We will first develope a simple text box which will be non-editable to show the contents of the chat
We have set the submit action of the form to false so that the page doesn't load again whenever the user submits the form. Function searchKeyPress will be triggered whenever a key is pressed. It checks whether the key was a return key. The main chat button also has a onClick event handler which responds whenever one presses the Chat button.
Once we are done with the form part, lets move to the Jscript and Ajax part which acts as main engine in our chat.