26.05.2015 Views

o_19m7st4t316nvv6a1bg63l10e4a.pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

http://www.adaptivepath.com/publications/essays/archives/000385.php.<br />

However, the word is really a bit of a misnomer: AJAX doesn't really rely on<br />

XML at all, but rather on a JavaScript function that happens to be named<br />

XMLHttpRequest.<br />

All About XMLHttpRequest.<br />

XMLHttpRequest was originally invented and implemented by a Microsoft<br />

team who were working on a webmail application, and it's been around for a<br />

while now (since 1999, in fact). The reason it has suddenly come to<br />

prominence now is that Google used it in three projects, Gmail, Google<br />

Suggest and Google Maps, and in each case managed to create a much<br />

better user interface than they would have been able to otherwise.<br />

So what does XMLHttpRequest do? To put it simply, it lets your JavaScript go<br />

back to the server, fetch some new content, and write it back out onto the<br />

page – all without the user having to change pages. This gives a 'smoother'<br />

feel to web applications, as they can do things like submit forms without the<br />

whole browser window needing to go blank and reload the page. Take a look<br />

at maps.google.com now, and notice how you can drag the map around<br />

anywhere you want to go without having to reload the page. This would be<br />

unthinkable without XMLHttpRequest.<br />

One of the biggest reasons XMLHttpRequest has become popular now is that<br />

browsers other than Internet Explorer have started to support it, mainly due<br />

to the fuss over its use in Gmail. The function is, by all accounts, a very<br />

simple one in technical terms: it was just a matter of someone having the<br />

idea.<br />

Getting Started with AJAX.<br />

The first thing to do to get started with AJAX, then, is to create an<br />

XMLHttpRequest object in your JavaScript code. As ever, Internet Explorer<br />

has to be difficult, doing this a different way to every other browser out<br />

there. That means that you should use this JavaScript code:<br />

var ajax;<br />

onload = function () {<br />

if (window.ActiveXObject) {<br />

The Web Design Guide for Newbies |83

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!