jQuery AJAX Introduction
The following figure illustrates the Ajax functionality.
|jQuery Ajax Methods
|Sends asynchronous http request to the server.
|Sends http GET request to load the data from the server.
|Sends http POST request to submit or load the data to the server.
|Sends http GET request to load JSON encoded data from the server.
|Sends http request to load the html or text content from the server and add them to DOM element(s).
The jQuery library also includes following events which will be fired based on the state of the Ajax request.
|jQuery Ajax Events
|Register a handler function to be called when Ajax requests complete.
|Register a handler function to be called when Ajax requests complete with an error.
|Register a handler function to be called before Ajax request is sent.
|Register a handler function to be called when the first Ajax request begins.
|Register a handler function to be called when all the Ajax requests have completed.
|Register a handler function to be called when Ajax request completes successfully.
Advantages of jQuery Ajax
- Cross-browser support
- Simple methods to use
- Ability to send GET and POST requests
- Ability to Load JSON, XML, HTML or Scripts
Let's look at an overview of important jQuery Ajax methods in the next section.