Benefits of AJAX
There are 4 main benefits of using AJAX in web applications:
- Callbacks: AJAX is used to perform a callback, making a quick round trip to and from the server to retrieve and/or save data without posting the entire page back to the server. By not performing a full postback and sending all form data to the server, network utilization is minimized and quicker operations occur. In sites and locations with restricted bandwidth, this can greatly improve network performance. Most of the time, the data being sent to and from the server is minimal. By using callbacks, the server is not required to process all form elements. By sending only the necessary data, there is limited processing on the server. There is no need to process all form elements, process the ViewState, send images back to the client, or send a full page back to the client.
- Making Asynchronous Calls: AJAX allows you to make asynchronous calls to a web server. This allows the client browser to avoid waiting for all data to arrive before allowing the user to act once more.
- User-Friendly: Because a page postback is being eliminated, AJAX enabled applications will always be more responsive, faster and more user-friendly.
- Increased Speed: The main purpose of AJAX is to improve the speed, performance and usability of a web application. A great example of AJAX is the movie rating feature on Netflix. The user rates a movie and their personal rating for that movie will be saved to their database without waiting for the page to refresh or reload. These movie ratings are being saved to their database without posting the entire page back to the server.
How AJAX Works
- An event occurs in a web page (the page is loaded, a button is clicked)
- The XMLHttpRequest object sends a request to a web server
- The server processes the request
- The server sends a response back to the web page
Things To Know
- AJAX just uses a combination of:
- A browser built-in XMLHttpRequest object (to request data from a web server)
- AJAX is a developer’s dream, because you can:
- Update a web page without reloading the page
- Request data from a server – after the page has loaded
- Receive data from a server – after the page has loaded
- Send data to a server – in the background
- AJAX uses XHTML for content, CSS for presentation, along with DOM and JS for dynamic content display.
- Conventional web applications transmit information to and from the server using synchronous requests – being directed to a new page with new information from the server.
- 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.
- Allows a developer to create an intuitive and natural user interaction.
- With AJAX clicking is not required, mouse movement is a sufficient event trigger.
- AJAX is data-driven as opposed to page-driven