What is AJAX?
AJAX gained significant usage as the technology that repopulates scrolling feeds, such as those found in Twitter and Facebook, or drives the smooth user experience in Google Maps without any special plugins. It allows the HTML site to cache, then can seamlessly re-populate a site with personalized updates via AJAX request, such as filling cart information or providing product recommendations.
AJAX uses a browser built-in `XMLHttpRequest` object to request data from a Web Server and HTML DOM to display or use the data. `New XMLHttpRequest Object` is an API in the form an object whose methods help in transfer of data between a web browser and a web server. When a web page is loaded, the browser creates a Document Object Model of the page, then updates dynamically by calling the XMLHttpRequest Object API. Web developers use JSON to pass AJAX updates between the client-side and the server-side, as commonly advised in online tutorials.
AJAX has four major benefits:
- Callbacks- by pulling information from a server without having to retrieve the whole website again, AJAX calls are more efficient.
- Asynchronous calls - This means the client isn't left waiting for all the data to arrive before continuing.
- Eliminates a postback.
- 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, and without posting the entire page back to the server.