Internal Guide: Presented By-Rajeshwari Archana Akshari Hegde Lecturer, GSSSIETW Lecturer, GSSSIETW (4GW07CS001)

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 15

AJAX

Internal Guide: Presented by-


Rajeshwari Archana Akshari Hegde
Lecturer,GSSSIETW Lecturer,GSSSIETW [4GW07CS001]
AJAX Outline

• Introduction

• History of AJAX

• Components of AJAX

• How AJAX works?

• Classic Web vs. AJAX


Introduction

• Asynchronous Javascript and XML(AJAX).


• Not a stand-alone language or technology.
• It is a technique that combines a set of known technologies in
order to create faster and more user friendly web pages.
• It is a client side technology.
Classic vs. AJAX

Interrupted
user
operation
while
the data is
being
fetched

Uninterrupted
user operation
while data is
being fetched
History of AJAX

• Hidden Frames since mid-90’s.


• In 2005, Jesse James Garret wrote an article on AJAX
named “Ajax: A New Approach to Web Applications “.
Examples of AJAX

• Google Maps
• Flickr
• Bindows
• Google Suggest
• NetFlix
• Gmail
Components of Ajax

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 binding everything together.
How AJAX works?

• AJAX runs in your browser

• Works with asynchronous data transfers(HTTP requests)


between the browser and the web server

• Http requests are sent by javascript calls without having to


submit a form

• XML is commonly used as the format for receiving server data


but plain text may be used as well
How AJAX works? (contd.)

1 – XMLHttpRequest object

• A page element must make a javascript call

• The javascript function must create an XMLHttpRequest


object which is used to contact the server

• Javascript must determine whether the client is IE or Firefox

• http = new ActiveXObject("Microsoft.XMLHTTP"); (IE)

• http = new XMLHttpRequest(); (Mozilla)


How AJAX works? (contd.)

2 - Sending the request

• Once the XMLHttpRequest object has been created it must be


set up to call the server
• The code above utilizes the XMLHttpRequest object to
contact the server and retrieve server data
• When the response returns the javascript method
jsMethodToHandleResponse can update the page
How AJAX works? (contd.)

3 - Handling the Response

• Implementation of the javascript method which will be used to


handle the response (Event Handler)

• function jsMethodToHandleResponse(str)
{
document.getElementById("result").innerHTML = str;
}

• Now the page has communicated with the server without


having to refresh the entire page
How AJAX works? (contd.)

Fig. AJAX data transfer between server and client


Advantages of AJAX

• Independent of server technology.

• Processing is same for all browser types, because


Javascript is used.

• Permits the development of faster and more interactive


web applications.

• Decreases bandwidth.

• Reduces connections to web servers.


Disadvantages of AJAX

• May not register with browser’s history engine, making back


button only semi-functional.

• Does not work well with search engine optimization.

• Does not work if user has JavaScript disabled in browser.

• Possible network latency problems.

• Does not run on all browsers.

You might also like