AJAX stands for Asynchronous JavaScript And XML. It is a set of web development techniques that allows a web page to communicate with a server in the background - without reloading the entire page. The result is a faster, more interactive user experience.
The term AJAX was coined by web designer and developer Jesse James Garrett in February 2005 in his essay "Ajax: A New Approach to Web Applications". Although the underlying technologies (XMLHttpRequest, JavaScript, DOM) had existed for years, Garrett was the first to group them under a single name and articulate their combined power.
Despite the name, modern AJAX rarely uses XML. Today, JSON (JavaScript Object Notation) is the dominant data format because it is lighter and natively supported by JavaScript.
In a traditional web app, every user interaction that requires new data triggers a full page reload. AJAX breaks that pattern by sending and receiving data in the background.
| Feature | Traditional Web App | AJAX Web App |
|---|---|---|
| Page reload on data fetch | Yes - full reload | No - partial update |
| User experience | Interrupted, slow | Smooth, fast |
| Server load | Higher (full HTML each time) | Lower (only data transferred) |
| Browser history | Automatic | Requires manual management |
| SEO friendliness | Easier by default | Requires extra effort |
| Complexity | Simpler | More complex |
Here is the high-level flow of an AJAX interaction:
XMLHttpRequest object or calls fetch().// Step 1: Create an XMLHttpRequest object
const xhr = new XMLHttpRequest();
// Step 2: Configure the request (method, URL, async flag)
xhr.open('GET', 'https://api.example.com/users', true);
// Step 3: Define what happens when the response arrives
xhr.onload = function () {
if (xhr.status === 200) {
const users = JSON.parse(xhr.responseText);
console.log('Users received:', users);
// Step 5: Update the DOM without reloading the page
const list = document.getElementById('user-list');
list.innerHTML = users.map(u => `<li>${u.name}</li>`).join('');
}
};
// Step 4: Send the request
xhr.send();
// Modern AJAX using the Fetch API (ES6+)
fetch('https://api.example.com/users')
.then(response => response.json()) // parse JSON response
.then(users => {
// Update the DOM with received data
const list = document.getElementById('user-list');
list.innerHTML = users.map(u => `<li>${u.name}</li>`).join('');
})
.catch(error => {
console.error('AJAX request failed:', error);
});
Explore 500+ free tutorials across 20+ languages and frameworks.