Everyday Computing Advanced Computing The Internet At Home Health, Mind & Body Making & Managing Money Sports & Leisure Travel Beyond The Classroom
Building Web Sites
Doing Business Online
Graphics & Animation
Using the Internet
Moms, Dads, and Grads -- Win $500!
Ajax For Dummies
A Developer's Perspective of How Ajax Works
Adapted From: Ajax For Dummies

Historically, innovative new projects are typically online, but Web programmers still feel that the rich capabilities of desktop software are out of their reach. But Ajax is closing the gap.

How does Ajax do its stuff? The name Ajax is short for Asynchronous JavaScript and XML, and it's made up of several components:

  • Browser-based presentation using HTML and Cascading Style Sheets (CSS)
  • Data stored in XML format and fetched from the server
  • Behind-the-scenes data fetches using XMLHttpRequest objects in the browser
  • JavaScript to make everything happen

JavaScript is the scripting language that nearly all browsers support, which will let you fetch data behind the scenes, and XML is the popular language that lets you store data in an easy format. Here's an overview of how Ajax works:

  1. In the browser, you write code in JavaScript that can fetch data from the server as needed.

  2. When more data is needed from the server, the JavaScript uses a special item supported by browsers, the XMLHttpRequest object, to send a request to the server behind the scenes -- without causing a page refresh. The JavaScript in the browser doesn't have to stop everything to wait for that data to come back from the server. It can wait for the data in the background and spring into action when the data does appear (that's called asynchronous data retrieval).

  3. The data that comes back from the server can be XML or just plain text if you prefer. The JavaScript code in the browser can read that data and put it to work immediately.

That's how Ajax works -- it uses JavaScript in the browser and the XMLHttpRequest object to communicate with the server without page refreshes, and handles the XML (or other text) data sent back from the server.


To find out how to have Dummies eTips delivered to your e-mail inbox every week, visit the Dummies eTip Sign-Up Page.
Related Articles
Deciding Your Use for HTML
Specifying Size and Position with CSS
Introducing the Advantages of Style Sheets
Giving Search Engines Something to Read
Figuring Out What URLs Are Made Of
Related Titles
HTML, XHTML & CSS For Dummies, 6th Edition
Ajax For Dummies
XHTML For Dummies
XML All-in-One Desk Reference For Dummies
HTML 4 For Dummies, 5th Edition