What is AJAX?
AJAX stands for Asynchronous Javascript And XML. It’s really just a big complicated word that doesn’t really tell you anything about what it really is.
AJAX is a technique that allows a web page to communicate with a server without reloading the page. The key thing to remember is that it’s a TECHNIQUE. It’s a combination of existing technologies that work together to create a new and exciting result. There is nothing new to install on the server. There is nothing that the user needs to install, other than a web browser that supports javaScript.
To use AJAX you’ll need a few basic ingredients:
A web browser that supports javaScript
JavaScript
A web server
A server-side language of your choice (perl, php, c#, etc.)
JavaScript allows you to dynamically alter the layout and information of a page that is being displayed in the browser. “Dynamically” means that the changes happen in real time without having to reload the page. Everything happens on the client (in the browser). The problem is that the dynamicness is limited to the data that is already on the page, or the simple calculations that can be done in javaScript.
On the other hand, server-side languages allow powerful calculations and make it very easy to read and write data in databases and on the filesystem. Unfortunately, every call to the server requires you to reload and run the script. A typical server-side access happens as follows:
You click a button on the front end page. The browser redirects to the processing page as it submits the data to the server. The server sends the information back to the browser. The browser reloads with the new information. See figure A.
The trick with AJAX is to combine the best of both worlds through the use of a magical AJAX object. There are a couple of different kinds of magical AJAX objects. Some people use the javascript httpRequest object (in combination with an ActiveX control for Internet Explorer). Other people use standard HTML iFrames. Each has its own strengths and weaknesses. Which is better really depends on whom you’re talking to, but they all do the same thing.
AJAX requests happen as follows:
You click a button on the front-end page. The browser submits the request through the magic AJAX object. The server processes the back-end page inside the magic AJAX object. When the processing is done, the front-end page uses javaScript to grab the data from the magic AJAX object. The javaScript takes the data and adds it to the front-end page without ever having to reload. See figure B.
In conclusion, AJAX is a technique that utilizes the strengths of both dynamic client-side scripting (javaScript) and powerful server-side processing. Web applications that utilize AJAX are generally a great deal faster and increase the user experience tremendously. A user does something and the page responds accordingly, in real time. AJAX is an important part of any web developer’s toolbox. So stay armed with AJAX. It’s stronger than dirt.
Until next time,
~~Ben
Wisdom Archive
- August 2008 (2)
- July 2008 (2)
- June 2008 (3)
- May 2008 (3)
- April 2008 (4)
- March 2008 (7)
- February 2008 (6)
- January 2008 (1)
- December 2007 (3)
- November 2007 (9)
- October 2007 (26)
- August 2007 (1)
- June 2007 (1)
- May 2007 (1)
- March 2007 (1)
- February 2007 (2)
- December 2006 (4)
- November 2006 (4)
- October 2006 (5)
- September 2006 (2)
- August 2006 (1)
Categories
- poonheads (22)
- music (17)
- comic (16)
- site news (12)
- coding (11)
- Classic Wisdom (10)
- video (10)
- I Love Music (9)
- javascript (9)
- photo (9)
- rant (8)
- tutorial (8)
- web design (8)
- hardware (7)
- hobby (7)
- mustaches (7)
- gear (6)
- horrifying (6)
- story time (6)
- earworm (5)
- food (5)
- art (4)
- software (4)
- Coding for Complete Noobs (3)
- movie (3)
- Captain Numbskull (2)
- Everyday Wisdom (2)
- beverage (2)
- knives (2)
- review (2)
- toys (1)
Saturday, November 17, 2007
AJAX redeux (now, with 20% less profanity and 100% less code)
Labels:
coding,
javascript,
tutorial