English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
AJAX allows for
This means that certain parts of the web page can be updated without reloading the entire page, which also provides a better user experience and improves data transmission speed.
The jQuery library has a full set of AJAX functions.
The functions and methods in it allow us to load data from the server without refreshing the browser page.
When any AJAX event (such as initialization or completion) occurs on any AJAX request on the page, these methods will attach a function to be called:
These methods perform more common Ajax request types with less code: | Method |
---|---|
ajaxComplete() | Attach a function to be called when an AJAX request is completed. This is an AJAXEvent |
ajaxError() | Attach a function to be called when an AJAX request is completed and an error occurs. This is an AJAX event |
ajaxSend() | Attach a function to be called before sending an AJAX request. This is an AJAX event |
ajaxStart() | Attach a function to be called before the first AJAX request starts. This is an AJAX event |
ajaxStop() | Attach a function to be called when all AJAX requests have been completed. This is an AJAX event |
ajaxSuccess() | Attach a function to be called whenever an AJAX request is successfully completed. This is an AJAX event |
These functions help with common idioms encountered when performing AJAX tasks:
These methods perform more common Ajax request types with less code: | Method |
---|---|
$.param() | Create a serialized representation of an array or object (which can be used as a URL query string for AJAX requests) |
serialize() | Encode a set of form elements as a string to be submitted |
serializeArray() | Encode a set of form elements as an array of names and values |
Low-level Interface
These methods perform more common Ajax request types with less code: | Method |
---|---|
These methods can be used to send any Ajax request: | $.ajax() |
Execute asynchronous HTTP (AJAX) requests | $.ajaxPrefilter() |
Process custom Ajax options or modify existing options before sending each request and before $.ajax() handles them | $.ajaxSetup() |
Set default values for future AJAX requests. Not recommended for use | $.ajaxTransport() |
Shorthand Methods
These methods perform more common Ajax request types with less code: | Method |
---|---|
Description | $.get() |
Load data from the server using HTTP GET request | $.getJSON() |
Load JSON-encoded data from the server using GET HTTP request | $.getScript() |
Load (and execute) a JavaScript file from the server using GET HTTP request | $.post() |
Load data from the server using HTTP POST request | load() |