Datasheet

In fact, XML is only one of the ways to handle data sent to you from the server. You can also send
back plain text as well, and you’re going to see both techniques extensively in this book.
Besides JavaScript and XML, Ajax also works with dynamic HTML and Cascading Style Sheets
(CSS). Both of these technologies allow you to update the data displayed in a Web page, and,
because you don’t redraw the entire Web page with Ajax, but just a part of it, you rely on dynamic
HTML and CSS quite a bit; both of them allow you to update specific parts of a Web page. You’re
going to see a lot more on dynamic HTML and CSS in this book because they allow you to refresh
just part of a Web page, something that is central to Ajax-enabled applications.
The part of JavaScript that makes Ajax possible is the
XMLHttpRequest object. This is a special
object built into all modern browsers’ version of JavaScript. As you’re going to see, this is what
makes it possible to connect to the server and handle data sent back from the server behind the
scenes. It’s not just JavaScript that makes Ajax tick, it’s the
XMLHttpRequest object inside
JavaScript.
So there you have it; Ajax is a collection of technologies, not just a single technology. You use
the
XMLHttpRequest object built into JavaScript to connect to the server, and then handle the
XML or plain text the server sends back using JavaScript. And you use dynamic HTML and CSS
to display the results in the browser. It’s lucky that all the parts of Ajax applications came together
as they did JavaScript, the
XMLHttpRequest object, dynamic HTML, and CSS because all
together, they make it possible to make your online applications look like desktop applications.
Actually, the technology for Ajax has been around since 1998, and had already been used by a
number of applications such as Microsoft’s Outlook Web Access. But it didn’t really catch on until
early 2005 when some high-profile applications such as Google Suggest put it to work, and Jesse
James Garrett wrote his article coining the term Ajax, which put everything under one roof.
Since that time, things have exploded as developers have realized that Web software can finally
start acting and behaving like desktop software. So what can you do with Ajax? That’s what the rest
of this chapter is about.
What Can You Do with Ajax?
There’s a great deal you can do with Ajax, and the following pages cover this treasure trove in some
detail. Coming up is a good survey of the way Ajax is used today.
Create Ajax live searches
One of the most popular uses of Ajax is to create live searches, and you’ve already seen an example
with Google Suggest at the beginning of this chapter. With a live search, the user can enter a partial
search term, and using Ajax, the Web application connects to the server and finds matches to that
partial search term.
8
Fundamental Ajax
Part I
06_102633 ch01.qxp 2/23/07 9:44 PM Page 8