What is ajax? How do I download ajax? Who owns the ajax software? Is ajax the software running Web 2.0? So what the heck is ajax!
I get asked about AJAX by beginning web site builders all the time. After giving a brief technical explanation, the person usually is still a bit confused. Seems they have their head wrapped around the idea of some sort of programming language or pre compiled software. So here is another attempt to explain it with a few links to code examples, books, and other articles.
Simply put, AJAX is a catchy word coined in 2005 by Jesse James Garret to describe a programming technique or design philosophy. Still can't wrap your head around the idea of AJAX? Ok, think of AJAX as a triathlon, a combination of three sporting events that use swimming, running, and cycling to make up the triathlon event. It's safe to say that swimming, running, and cycling events have been around for a very long time. It is also very possible that many athletes combined all three activities during their training for a very long time as well. But it wasn't until the early 70's that the combination as a sporting event or training regimen was given the name Triathlon. Well, AJAX is the same deal; a combination of scripting and markup languages that have been around for a long time but now have a cool fancy name to describe their use in conjunction with each other.
Without going into too much detail, most applications written with the "AJAX technique" use DOM, JavaScript, XML, and usually some sort of server side scripting language such as PHP, ASP, ColdFusion, or Java to generate the XML. One of the key components of the technique is the use of javascript with the XMLHttpRequest API. Just think of XMLHttpRequest as a "gofer".
Uhhh... DOM, JavaScript, Server Side Scripting???
The Document Object Model (DOM) is basically the blueprint for your HTML page. DOM puts everything on the web place in a particular place with a name or id so you can access the parts that will be modified. If you don't know the name or id of the part, you have no way of making contact with it. This is where the DOM comes into play.
JavaScript is the language used to talk with the parts of the DOM. Now that you know the name or ID of the page parts, you need a way to talk with them to tell the parts what to do, right? This is where JavaScript comes into play. A piece of JavaScript communication can be similar to:
"If the user clicks on a button named MrButton, go to the server and collected data that relates to the value typed in the text field box named ABoringTextFieldBox. If the server finds some results, change ABoringTextFieldBox into a table with the results. If the server does not find any results, leave the ABoringTextFieldBox alone but add a message next to saying nothing was found."
The Server Side Scripting part of AJAX is the language used on the computer (server) that is serving up the pages to you. Most likely the server side scripting language will have access to some sort of database and the computer will be housed in a large data center with lots of cool blinking LED lights and loads of underground space for Halon gas and network cabling.
Every application that uses the AJAX technique will benefit differently depending on the need. However, one of the key benefits that many application programmers would have to agree on is the reduction of server load, bandwidth, latency, and code size. This is done by limiting the need to refresh the page to load new data in the browser window. For example, follow this link and look up a few domain names. You will notice that the page does not refresh but you are given a response indicating whether the domain is available or not. Now image how much bandwidth and server load you would use if you had the user refresh the page for every search. This becomes especially important when dealing with dynamic content as some applications will request the browser to refresh the cache with every page request.
Still don't understand the benefits? Ok, if you had a large family over for dinner and noticed you did not have enough ketchup for little johnny's french fries, you wouldn't gather up the whole family to go to the store to fetch the ketchup and then rush back home to sit down at the table would you? Of course not. You would send the gofer ( Big Dave AKA "XMLHttpRequest" ) to GET the ketchup, put it on the table, and then go back to hiding in the kitchen until called again to fetch something else. That's exactly what you are doing with AJAX via the XMLHttpRequest API. Instead of reloading all the page contents again, you send a request for a small portion of the page and then update it with the new data.
Besides the standard security concerns that will plague us to the end of human existence, the usual "too much of a good thing" applies here. Applications that rely heavily on AJAX to modify a single page often create page rendering nightmares that stem from the lag created between request to the server. You also have an issue with the modifications to the document object model which may also hang while waiting for the request to finish. Find a site that you move your cursor from one side of the page to the other and the site automatically starts firing off numerous balloon pop-ups or advertising windows with text fields for data. When ever you come across this type of site, you've most likely found a page with AJAX overload. Some developers who love flashy sites tend to over use the feature in order to rendered the page as a cosmic array of activity that is completely useless after the first few seconds of viewing the page. Other spammy sites use ajax in hopes of you accidentally clicking on a revenue generating links. Often times to the point that JavaScript must be turn off completely in order to navigate the site for what you are looking for. Most of the abuse problems can be attributed to excessive use of JavaScript, however, with the increasing popularity of AJAX, those little popup text fields and advertisements now send data back to the server via XMLHttpRequest.
Just remember a little ajax can go a long way if used efficiently.