AJAX is short for **Asynchronous JavaScript and XML**. It is the most powerful technique in modern web development because it allows you to update parts of a web page **without reloading the entire page**. This creates a seamless, "App-like" experience for your users.
Normally, when you click a link or submit a form, the browser reloads. With AJAX, your JavaScript code sends a request to the server "in the background." When the server replies, you can use jQuery to update just the part of the page that needs to change.
Writing raw AJAX in plain JavaScript is notoriously difficult because different browsers (especially older ones) have different ways of handling it. You would have to write dozens of lines of code just to handle simple errors.
jQuery reduces all that complexity into single-line methods.
In the following lessons, you will learn the three main ways jQuery handles AJAX:
| Method | Best Used For... |
|---|---|
load() |
The simplest way. it loads data from a server and puts it directly into an element. |
$.get() / $.post() |
The standard way. it sends or receives data from a server using HTTP requests. |
$.ajax() |
The expert way. Total control over headers, timeouts, and specific logic. |
$.get(...) executes immediately, before the response arrives. Any code that needs the response must live inside the success callback.
.fail() (or an error: callback) so users see feedback instead of a silently broken page.
A second example — fetching a JSON endpoint and displaying part of the response, with an explicit failure handler:
$.get("/api/user-status.json")
.done(function(data) {
$("#status").text("Status: " + data.status);
})
.fail(function() {
$("#status").text("Could not load status. Please try again.");
});
Q: Does AJAX require jQuery?
A: No — the browser's native fetch() API can do everything jQuery's AJAX methods do. jQuery just predates fetch() and offers a more consistent cross-browser API for older codebases.
Q: What does the X in AJAX actually mean today?
A: Historically "XML," but modern AJAX overwhelmingly exchanges JSON instead — the name stuck even though the data format changed.
Q: How do I send data to the server, not just receive it?
A: Use $.post() or $.ajax() with a data option. See the official $.ajax() documentation for every configuration option.