AJAX uses an object of XMLHttpRequest for the communication between the application and the server.
Here is the work flow of AJAX:
- XMLHttpRequest object sends HTTP Request to the server.
- Server received data and interacts with the database if needed.
- Server processes the data and sends the result back to the XMLHttpRequest callback function.
- Output(HTML, CSS) is displayed on the webpage.
jQuery and AJAX:
Different browsers have different syntax for AJAX. This makes it hard for the developers to write AJAX code that supports all the browsers. This issue has been solved by the jQuery since it takes care of the browser compatibility.
The load() method loads data from the server and shows the result in the selected element.
The get() and post() methods are used to request data from the server.