Вы находитесь на странице: 1из 3

What is Ajax?


Ajax, which stands for Asynchronous JavaScript and XML, is a set of techniques for creating

highly interactive web sites and web applications. The idea is to make what’s on the Web appear to be

local by giving you a rich user experience, offering you feature that usually only appear in desktop


A Good Acronym:

• A is for ―asynchronous‖

requests can be made asynchronously or synchronously

both techniques allow web page to be updated without refreshing it

anything useful the user can do while processing request

• J is for ―JavaScript‖

typically JavaScript is used on the client-side (in the browser)

only programming language supported out-of-the-box by most web browsers

can use any language on server-side that can accept HTTP requests and return HTTP responses

• Java servlets, Ruby servlets, CGI scripts…

• X is for ―XML‖

request and response messages can contain XML

can easily invoke REST-style services

can really contain any text (single text value, delimited text, …)

The emphasis in Ajax applications is to update the web page, using data fetched from

the Internet, without refreshing the web page in the browser.

Ajax isn’t a technology. It’s really several technologies, each flourishing in its own right,

coming together in powerful new ways. Ajax incorporates:

standards-based presentation using XHTML and CSS;

dynamic display and interaction using the Document Object Model;


data interchange and manipulation using XML and XSLT;

asynchronous data retrieval using XMLHttpRequest;

and JavaScript

Ajax is made up of several componentsJavaScript, the XMLHttpRequest object, dynamic HTML,and so onthat have been around since 1998. And before Ajax had been formally introduced, it had already been used by a few applications (such as Microsoft’s Outlook Web Access). But Ajax didn’t really take off until 2005, with the introduction of new applications, such as Google Suggest, and Jesse Garrett’s famous article collecting all the parts together into the single term Ajax.

How Ajax works?

As you can see, Google Suggest gives Google the feeling of a desktop applicationat least partially: the screen still flickers when the browser navigates to Google to look up the term you’ve clicked in the drop-down list . That’s the main idea behind Ajax: taking interaction from the Internet and making it seem local, as if the application were right there on your computer.

In other words, Ajax is an umbrella term for techniques you use to make web applications look like desktop applications. Here’s how it works: In the browser, code written in a scripting languagemost frequently, JavaScriptwatches what information the user wants, such as what term they’re searching for in Google Suggest. When,or even before, the user needs that information, the JavaScript code communicates with the web server behind the scenes to fetch that information without causing a page refresh in the browser.That is, the way Ajax fetches data from the server is invisible to the user. The JavaScript code uses a special object built into the browseran XMLHttpRequest objectto open a connection to the server and download data from the server. That data is often in XML format(the x in Ajax stands for XML), but it can be just plain text, as you’re going to see.

When the data that the user needs has been downloaded behind the scenes, the JavaScript code uses that data to update the display in the browser. For example, in the earlier Google Suggest example, JavaScript was responsible for fetching, behind the scenes, the suggestions Google made and then displaying those suggestions in the drop-down list box after they were downloaded.



Purpose of Ajax:

Prevents unnecessary reloading of a page.

When we submit a form, although most of the page remains the same, whole page is reloaded from the server.

This causes very long waiting times and waste of bandwidth.

AJAX aims at loading only the necessary innformation, and making only the necessary changes on the current page without reloading the whole page.

Uses of Ajax:



• Google Maps – http://maps.google.com

Asynchronously loads graphic tiles to support map scrolling

• Google Suggest – http://www.google.com/suggest

Asynchronously updates list of possible topic matches, based on what has been

typed so far.


Even when there is nothing useful for the user to do after a request is submitted to a server Ajax can be used to retrieve data and update selected parts of the page without refreshing the entire page.

In a nutshell, it is the use of the XMLHttpRequest object to communicate with server-side scripts.

Examples of Ajax:

Google Suggest

Google map