As a software developer and a beginner to AJAX, I can certainly say that the acronym “Asynchronous JavaScript And XML” is not very helpful in understanding how this incredible technology revolutionized the way information is accessed and made Web 2.0 development possible. To put it simply, AJAX is a method of accessing information on a server and displaying it without interrupting the user’s work on the web page. The traditional paradigm for web information access relied on navigation from page to page, with each page remaining a static representation of content. AJAX allows users to request additional information to be displayed on the web page without requiring a full refresh of the page. Today’s biggest web applications work exactly in this way. What gives these web pages the feel of desktop applications is that the archaic method of accessing information in a page by page manner has been done away with: there is no more pause and screen refresh in between user actions, the information is queried from the server and displayed asynchronously with respect to the work-flow of the web page. In this manner, AJAX web pages are much more usable and extend the functionality of static web pages by a long shot.
The main web design tool that makes AJAX work is JavaScript, a client-side scripting language that has been around since 1995. “Client-side” means that the programs written in JavaScript (or scripts) run on the user’s computer, affecting only the content displayed in the user’s browser. JavaScript has been traditionally used for accomplishing tasks such as displaying pop-up windows and validating form field input. AJAX utilizes the JavaScript XMLHTTPRequest object to make asynchronous requests to the server for additional information. When an XMLHTTPRequest is used in a script, the programmer must specify the server to which it will be sent, in addition to the query parameters and a callback function. A callback function is exactly what it sounds like: it is the function that is invoked when the server “calls back” or finishes processing the client’s request and sends back some data. After the server responds to the XMLHTTPRequest, the callback function is invoked and processes the data that the server returned. The callback function is also responsible for displaying the data to the user.
Hopefully the description above is not too complicated, even for a non-technical audience. The key point here is that this entire process does not require the browser to refresh the page or interrupt the user’s reading or work on the page. The information can be requested and displayed while the user continues to work. It is this dynamic page behavior that makes AJAX pages web applications.
To wrap this up, I’ll tell you about a classic example of AJAX usage that is very simple but remarkably powerful. Google Suggest is an extension of the Google search engine that displays a drop-down list of search “suggestions” and their corresponding numbers of search results as the user types in the text input field. These suggestions appear based on what the user has typed so far and a database of previous searches on Google. At any time the user can simply click on a suggestion and view its list of search results. To try out Google Suggest, click here. The suggestions are generated and displayed in the drop down list asynchronously via AJAX, without requiring a page refresh. This is just a small example of how basic AJAX functionality can transform a commonly used internet tool into a full-fledged web application.
Posted by dbencoded