Getting Started With AJAX
The basic steps:
Create a server-side application (ie: PHP script) that receives an HTTP request and returns data in XML or JSON format
Create a form
Add an event handler (aka: "go" button) to initiate the XML request
Instantiate the XMLHttpRequest object
Define the listener function for XMLHttpRequest.onreadystatechange event (Note: this is where most of your customized code will reside)
Open the connection with the server: XMLHttpRequest.open()
Send the request: XMLHttpRequest.send()
What happens when the "go" button is clicked:
The server-side app receives the HTTP request, then returns XML/JSON data, or an error message
The listener function (mentioned above) is called through the .onreadystatechange event
The listener function, interprets the XML/JSON response or error message from the server and responds accordingly using DOM interactions
Tutorials & Examples
AJAX Hello World
: using XML
AJAX Friends & Foes
: a complex data transaction using JSON
Some Helpful Links:
BrainJar: Intro to the DOM
© Mike Hall
BrainJar: DOM Event Model
© Mike Hall
PHP: JSON Functions
© The PHP Group
Apple Developer: DHTML/XML: The XMLHttpRequest Obj
© Apple Computer
XML.com: Very Dynamic Web Interfaces
by Drew McLellan
LINKMATRIX: XMLHttpRequest Tutorials
AJAX is not cool: pitfalls to avoid
Mozilla Dev Central: AJAX
Alex Bosworth: AJAX Mistakes
The AJAX Experience: Conference May 10-12th, 2006