13-10-2012, 05:35 PM
Asynchronous JavaScript and XML
What is Ajax.doc (Size: 177.5 KB / Downloads: 23)
This section explains you the Ajax. You will learn the basics of Ajax. Ajax is of the most important technologies for the development of highly interactive web application and due to its features it have become extremely popular these days.
What is Ajax?
Asynchronous JavaScript and XML or Ajax for short is new web development technique used for the development of most interactive website. Ajax helps you in making your web application more interactive by retrieving small amount of data from web server and then showing it on your application. You can do all these things without refreshing your page.
Usually in all the web applications, the user enters the data into the form and then clicks on the submit button to submit the request to the server. Server processes the request and returns the view in new page ( by reloading the whole page). This process is inefficient, time consuming, and a little frustrating for you user if the only the small amount of data exchange is required. For example in an user registration form, this can be frustrating thing for the user, as whole page is reloaded only to check the availability of the user name. Ajax will help in making your application more interactive. With the help of Ajax you can tune your application to check the availability of the user name without refreshing the whole page.
Understanding the technology behind Ajax
Ajax is not a single technology, but it is a combination of many technologies. These technologies are supported by modern web browsers. Following are techniques used in the Ajax applications.
• Java Script
JavaScript is used to make a request to the web server. Once the response is returned by the webserver, more JavaScript can be used to update the current page. DHTML and CSS is used to show the output to the user. JavaScript is used very heavily to provide teh dynamic behavior to the application.
• Asynchronous Call to the Server
Most of the Ajax application used the XMLHttpRequest object to send the request to the web server. These calls are Asynchronous and there is no need to wait for the response to come back. User can do the normal work without any problem.
• XML
XML may be used to receive the data returned from the web server. JavaScript can be used to process the XML data returned from the web server easily.
How Ajax Works?
When user first visits the page, the Ajax engine is initialized and loaded. From that point of time user interacts with Ajax engine to interact with the web server. The Ajax engine operates asynchronously while sending the request to the server and receiving the response from server. Ajax life cycle within the web browser can be divided into following stages:
• User Visit to the page: User visits the URL by typing URL in browser or clicking a link from some other page.
• Initialization of Ajax engine:
When the page is initially loaded, the Ajax engine is also initialized. The Ajax engine can also be set to continuously refresh the page content without refreshing the whole page.
• Event Processing Loop:
* Browser event may instruct the Ajax engine to send request to server and receive the response data
* Server response - Ajax engine receives the response from the server. Then it calls the JavaScript call back functions
* Browser (View) update - JavaScript request call back functions is used to update the browser. DHTML and css is used to update the browser display.
The impact of AJAX on user experience
AJAX user interfaces are highly responsive giving users the feeling that changes are instantaneous. It also introduces multiple segments of interactivity on the same page. User may submit a form and immediately after concentrate on some text or click on a menu item in some other segment. Even in case of an error in one segment other segments can stay usable. AJAX applications usually avoid the need of horizontal and vertical scrollbars, this adds to user convenience.
Existing AJAX applications can be categorized into two types 1) partially AJAXed - here AJAX is used to provide certain functionalities e.g. Flickr and 2) fully AJAXed - here AJAX is necessary for functionalities as well as for user-interface e.g. Meebo, Google Maps, Windows Live
The way users use fully AJAXed applications is very different from their traditional web experience. In these applications the concept of web pages breaks down, surfing a site or using an applications is not just clicking links and loading fresh pages. In some applications the response may result in changes to small/certain parts of the current view, the URL in the address bar remains unchanged and the Back, Forward, Reload and Bookmark buttons are rendered meaningless. The browser is not certain to show the previous state of the application on hitting Back/Forward buttons. Users need to adapt to this change in browser behavior.