Unit3 4
Unit3 4
Unit III
AJAX
• AJAX stands for Asynchronous JavaScript and XML. It is not a
technology in itself, but rather a suite of technologies. The
combination of JavaScript and XML allows for a responsive user
interface.
• Ajax is a group of technologies that provide asynchronous two-way
communication between a server and the web browser.
Asynchronous communication allows the user to continue to browse
the web page as sections of it are being loaded. This also allows the
page to display new and updated information without refreshing the
page.
AJAX
• Creating an Ajax request requires three sections of code, the first
section is writing in HTML, the second writing in JavaScript and
the third is a server script writing PHP. Each section of code
provides a different portion of the Ajax request, if the request is
missing any of the sections it will fail.
• AJAX is an acronym for Asynchronous JavaScript and XML. It
is not a technology in itself, but rather a suite of technologies.
The combination of JavaScript and XML allows for a responsive
user interface.
AJAX
• Makes interactive web pages by providing a way for the web page to
interact with the server
• AJAX is a framework
Synchronous Web Application Model:
Asynchronous Web Application Model: AJAX
How AJAX works
1. A JavaScript function creates and configures an XMLHttpRequest
object on the client, and specifies a JavaScript callback function.
2. The XMLHttpRequest object makes an asynchronous call to the web
server.
3. The web server processes the request and returns an XML document
that contains the result.
4. The XMLHttpRequest object calls the callback function and exposes
the response from the web server so that the request can be
processed.
5. The client updates the HTML DOM representing the page with the
new data.
How AJAX works
There is a 5-step approach for the browser to work with
AJAX:
objXMLHttp.onreadystatechange = procRequest;
objXMLHttp.readyState = [state];
State Description
Property 3: objXMLHttp.responseText
This property retrieves the data sent back from server.
var objVal = objXMLHttp. responseText;