2. AJAX
• Ajax is not a programming language/
technology.
• Ajax is a design approach and a set of
techniques for creating a highly interactive
user experience for web applications.
• It makes applications faster and user friendly.
4. AJAX BASICS
• AJAX uses XMLHttpRequest
• JavaScript communicates directly with the
server, through the JavaScript
XMLHttpRequest object.
• With an XMLHttpRequest, a web page can
make a request to, and get a response from a
web server without reloading the page.
5. BUILDING APPLICATIONS
AJAX Applications are:
• Three-tier client/ server apps
-Browser <-> App Server <-> Data Source
• Event driven
-User clicks, user drags, user change data
• Graphics Intensive
-Visual effects, Rich visual controls
• Are Data Oriented
-Users are manipulating and entering data
7. WORK OF AJAX
JavaScript
-Define an object for sending XML HttpRequest
i. Initiate request
• Get request object
• Designate a request handler function
-Supply as onreadystatechange attribute of
request
• Initiate a GET or POST request
• Send data
8. CONT…
ii. Handle response
• Wait for readyState of 4 and HTTP status of 200
• Extract return text with response Text or
response XML
• Do something with result
HTML
-Loads javaScript
-Gives ids to input elements that will be read by
script
9. DEFINE OBJECT
var request;
function getRequestObject()
{ if(window.ActiveXObject)
return(new ActiveXObject(“Microsoft.XMLHTTP”));
} else if (window.XMLHttpRequest)
return(new XMLHttpRequest());
} else{
return(null);
} }