Getting Started With AJAX

The basic steps:

  1. Create a server-side application (ie: PHP script) that receives an HTTP request and returns data in XML or JSON format
  2. Create a form
  3. Add an event handler (aka: "go" button) to initiate the XML request
  4. Instantiate the XMLHttpRequest object
  5. Define the listener function for XMLHttpRequest.onreadystatechange event (Note: this is where most of your customized code will reside)
  6. Open the connection with the server: XMLHttpRequest.open()
  7. Send the request: XMLHttpRequest.send()

What happens when the "go" button is clicked:

  1. The server-side app receives the HTTP request, then returns XML/JSON data, or an error message
  2. The listener function (mentioned above) is called through the .onreadystatechange event
  3. The listener function, interprets the XML/JSON response or error message from the server and responds accordingly using DOM interactions

Tutorials & Examples

Some Helpful Links: