Working of AJAX

Using XMLHttpRequest object, we can communicate with the server. Following are the steps how AJAX works-

How AJAX works
  1. The user generates event such as button click, selection of dropdown.
  2. Brower handles the event via a JavaScript and creates an object of XMLHttpRequest.
  3. Brower sends the request to the server for processing.
  4. The server processes the request by interaction with the databases using any one of the server-side programming languages like PHP, JSP, ASP.NET, etc.
  5. The server sends the response to the browser. And the browser receives the response in XMLHttpRequest callback function in the form of JSON or XML data.
  6. The browser updates the UI by making changes in HTML and CSS of a webpage without reloading the entire webpage.