Working of AJAX
Using XMLHttpRequest object, we can communicate with the server. Following are the steps how AJAX works-
- The user generates event such as button click, selection of dropdown.
- Brower handles the event via a JavaScript and creates an object of XMLHttpRequest.
- Brower sends the request to the server for processing.
- 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.
- 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.
- The browser updates the UI by making changes in HTML and CSS of a webpage without reloading the entire webpage.