Thursday, 20 February 2014

AJAX

How Ajax Works

At the heart of Ajax is the ability to communicate with a Web server asynchronously without taking away the user’s ability to interact with the page. The XMLHttpRequest is what makes this possible. Ajax makes it possible to update a page without a refresh.

What are Common Steps that AJAX Application Follows

The JavaScript function handEvent() will be invoked when an event occurred on the HTML element. In the handEvent() method, an instance of XMLHttpRequest object is created.

How Ajax Works in the Code

our DOM object is (input type="text" id="lblTime") which we have to refresh without refreshing the whole page. This will be done when we press the event of a button, i.e. onclick.

What is Ajax
Ajax (Asynchronous Javascript and XML ) is a technology used to load or retrieve the data from server without reloading or refreshing the Web page. Its a very good option in programming.
Example of Ajax

Google uses this ajax in each and every page. 
For example if you type some words in Google search box it shows some list of suggestion keywords. Listen how Google dynamically displaying the data when a user types in it, without reloading or refreshing the page?. 


Browser Support for AJAX?

Ajax can run in all type of browsers but their is a conflict in older (IE 5 and IE 6), and newer browsers (Mozilla, Netscape, IE 8, Chrome, Safari, Opera).
It can be rectified by checking the older and newer browser and implementing the below code.
For New Browsers: xmlhttp=new XMLHttpRequest();
For older Browsers: xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");


No comments:

Post a Comment