There are many questions that new developers often ask about Asynchronous Javascript and XML, in this post I will be answering some of the more common questions.
What is AJAX?
AJAX is a way of programming Javascript, kind of like DHTML. DHTML, in a nuthshell, is just a way of using Javascript (which runs on the user’s browser, and not on the server) to manipulate HTML elements as well as document data. DHTML is often used to dynamically create objects on your page, hence its name: Dynamic HTML.
AJAX is very similar, it is a way of using Javascript to send and receive data to the server, without forcing the user to reload a page. One bad part about the original design of the world wide web is that it required you to load and reload pages constantly. For example, just to check your bank information you may have to click on 5 different links and wait constantly for the pages to load.
Thanks to AJAX that will be a thing of the past. It is what gives the “extra finish” to popular web sites like Digg.com and Google Maps (one of the first, more popular sites to make use of it). Google Maps is a great example of what AJAX is, and how much power it has When you look up an address it will goto that address and display it in a map on the page. You can drag the map around and it will automatically fetch the needed images off the server. Much easier than constantly loading new pages.
AJAX itself is not a technology, it is just a name for a group of technologies that can be used together.
Why should I use AJAX for my web applications?
I think the answer I gave above pretty much answers this question. You should use AJAX because it is easy to use, and it makes your web applications seem much more professional.
People are spoiled, without a doubt. Three years ago no one minded having to load new pages to get updated data - nowadays people want it to happen automatically and behind the scenes.
Does AJAX cause compatibility issues?
It can, but just like any Javascript code you can easily add in extra code to detect whether or not it will work correctly on their browser, and then branch off to more compatible code as needed.
So, does AJAX require XML?
This is a hard question. On one side the aisle we have the nerds who think AJAX needs XML, after all it is an acronym for Asynchronous Javascript and XML. But on the other hand we have the geeks who think a script that gets plain text from asynchronous communications is as much an AJAX script as those that use XML.
What are some methods for data transfer (other than the default one)?
You could make your code dynamically include a Javascript file off the server, the file could be a PHP script that handles what it needs to handle and then prints out the JavaScript, which will then run on the user’s browser.
Another way is to use iFrames, but I really do not recommend doing it that way.
There really is no true definition as to how AJAX must be used. Some people think it must use XML to be a true AJAX application, but others think any script that can fetch data off the server at run-time is an AJAX application. It is a bit like the “My S Q L” vs “My Sequel” debate.
What are some good AJAX frameworks?
Click here for a long list of AJAX frameworks, and their pros + cons.
What is XMLHttpRequest?
XMLHttpRequest is an API that you can use to transfer and manipulate XML data. It is the default way of getting data from a server. For a more detailed look at the API, take a look at the Wikipedia entry.
Should I make my whole site AJAX based?
No, definitely do not do this. Most search engines search pages with Javascript turned off - you would have to add in so many hacks to make it compatible the script would be much bigger than it needs to be.
Where can I find some good AJAX info?
Wikipedia
Google
and W3 Schools
Please subscribe, or else I will cry. Do you really want to make a programmer cry?

Leave a Reply