6.4 AJAX (Asynchronous Java Script and XML) (Imp for short notes)

AJAX stands for Asynchronous JavaScript and XML. AJAX is a new technique for creating better,  faster, and more interactive web applications with the help of XML, HTML, CSS, and Java Script. 

Ajax is not a programming language or a tool, but a concept. Ajax is a client-side script that  communicates to and from a server/database without the need for a postback or a complete page  refresh 

∙ Ajax uses XHTML for content, CSS for presentation, along with Document Object Model  and JavaScript for dynamic content display. 

∙ Conventional web applications transmit information to and from the sever using  synchronous requests. It means you fill out a form, hit submit, and get directed to a new  page with new information from the server. 

∙ With AJAX, when you hit submit, JavaScript will make a request to the server, interpret  the results, and update the current screen. In the purest sense, the user would never know  that anything was even transmitted to the server.

∙ XML is commonly used as the format for receiving server data, although any format,  including plain text, can be used. 

∙ AJAX is a web browser technology independent of web server software. ∙ A user can continue to use the application while the client program requests information  from the server in the background. 

∙ Intuitive and natural user interaction. Clicking is not required, mouse movement is a  sufficient event trigger. 

∙ Data-driven as opposed to page-driven. 

Rich Internet Application Technology  

AJAX is the most viable Rich Internet Application (RIA) technology so far. It is getting  tremendous industry momentum and several tool kit and frameworks are emerging. But at the same  time, AJAX has browser incompatibility and it is supported by JavaScript, which is hard to  maintain and debug. 

AJAX is Based on Open Standards  

AJAX is based on the following open standards − 

∙ Browser-based presentation using HTML and Cascading Style Sheets (CSS). ∙ Data is stored in XML format and fetched from the server. 

∙ Behind-the-scenes data fetches using XMLHttpRequest objects in the browser. ∙ JavaScript to make everything happen. 

Benefits of Ajax  

There are four main benefits of using Ajax in web applications: 

∙ Callbacks 

∙ Increased Speed 

∙ Making Asynchronous Calls 

∙ User-Friendly 

With AJAX, web applications can send and retrieve data without reloading the whole web page.  This is done by sending HTTP requests to the server (behind the scenes), and by modifying only parts of the web page using JavaScript when the server returns data. 

The back bone of the AJAX technology is the XMLHttpRequest object. 

Methods Available with XMLHttpRequest 

∙ The open() Method: sets up a request to a web server. 

∙ The send() method: sends a request to the server. (Behind the scene. Client’s browser does  not refresh or takes any round trip.) 

∙ The abort() method : aborts the current server request.