AJAX supports data exchange with a web server behind the scenes and allows webpages to update asynchronously. This makes it possible to update parts of a particular webpage and display the results to a user quickly, without having to wait to reload the entire page.
AJAX is not a proprietary technology, programming language or a packaged product. Rather, it is a web browser technology and open standard that's independent of web server software. It can send and receive information from web servers in various formats, including the following:
- text files
The AJAX method uses a combination of technologies that allow the content on webpages to update immediately based on a user's action, which may be a click on a page or even a simple mouse movement. Just one or a few parts of the page may be refreshed, instead of reloading or refreshing the entire page. This differentiates AJAX from an HTTP request, during which users must wait for a whole new page to load. AJAX can also access data from external sources even after a webpage has loaded completely.
- cascading style sheets for presentation;
- DOM for dynamic content display; and
- Microsoft object, XMLHttpRequest to fetch data in the web browser.
The 'Asynchronous' in AJAX
- Once the HTML page loads, data is read from a web server.
- Without the need to reload the webpage, the data can be updated.
- Data transfer happens to the web server in the background.
All these asynchronous steps help create responsive HTML web content, as well as faster performance. As they achieve these goals, they help maintain a natural user interaction with webpages. Further, since AJAX is not dependent on web servers, it creates a data-driven environment rather than a page-driven environment. That's why it can execute tasks asynchronously and at any time.
To understand the workings of AJAX, it's important to remember that it has two key components: the web browser and the web server.
Here's how the process works:
- Some event happens on a webpage. For instance, the page loads, or a user clicks on a particular button.
- This object sends a request to the corresponding web server.
- The server processes the request and sends a response back to the browser.
AJAX applications and AJAX engine
AJAX applications don't require the installation of a plugin but work directly with a web browser. These applications usually use XML to transport data. However, they may also transport data as plaintext or JSON text (see the Understanding AJAX section).
Some key advantages of AJAX are as follows:
- AJAX is based on widely accepted open standards.
- It enhances the interactivity of webpages.
- It is highly efficient and fast for responsive web applications in e-commerce and other online platforms.
- It is a viable Rich Internet Application technology and is fairly synonymous with Web 2.0.
- AJAX supports intuitive user interactions.
- It allows content to be updated based on a specific user action, a time interval or some application-specific logic.
- Many open source toolkits and libraries are available to provide cross-browser support for AJAX-based interactions.
Disadvantages of AJAX
One drawback of AJAX-based applications is that they require increased communication between web browsers and web servers. This may result in application degradation due to the following:
- too many web server connections;
- too many packets traversing the network; and
- connection limitations implemented by browsers.
Applications of AJAX
Google Maps is one well-known application of AJAX. The interface allows users to change views and manipulate the map in real time.
AJAX can also be used to create the following:
- RSS readers
- desktop tutorials
- web-based chat applications
- calendar applications
- rating widgets
- contact and login forms
- charting components
See why collaboration is key to a secure web application architecture and how to apply web application reconnaissance fundamentals to improve offensive and defensive hacking skills.