What AJAX actually means today
TL;DR
AJAX (Asynchronous JavaScript and XML) is the umbrella term for making background HTTP requests from the browser without forcing a full page reload. The acronym is a relic — modern AJAX uses JSON over fetch, not XML over XMLHttpRequest — but the concept powers basically every interactive web app.
The idea
Pre-AJAX, every interaction with the server meant a round trip that replaced the entire HTML document. Click a link, submit a form, get a fresh page.
With AJAX, JavaScript fires a request in the background, consumes the response, and surgically updates just the part of the DOM that needs to change. The user never sees a reload.
The modern form: fetch
// GET requestasync function getUsers() {const response = await fetch('/api/users');const users = await response.json();return users;}// POST requestasync function createUser(name, email) {const response = await fetch('/api/users', {method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({ name, email }),});return response.json();}
The legacy form: XMLHttpRequest
Before fetch, every browser shipped with XMLHttpRequest:
const xhr = new XMLHttpRequest();xhr.open('GET', '/api/users');xhr.onload = function () {if (xhr.status === 200) {const users = JSON.parse(xhr.responseText);console.log(users);}};xhr.onerror = function () {console.log('Request failed');};xhr.send();
fetch replaced it for almost every use case — cleaner API, promise-based. XHR still shows up when you need upload-progress events or in older codebases.
AJAX in React
A basic pattern is useEffect + fetch:
function UserList() {const [users, setUsers] = useState([]);useEffect(() => {fetch('/api/users').then((res) => res.json()).then((data) => setUsers(data));}, []);return (<ul>{users.map((user) => (<li key={user.id}>{user.name}</li>))}</ul>);}
In production, most teams reach for a data-fetching library like React Query or SWR so they stop hand-rolling caching, loading states, and retries.
Interview Tip
Frame AJAX as the concept of asynchronous, non-reloading requests. Show fetch as today's canonical API, nod at XMLHttpRequest as the predecessor, and finish with the React pattern. If someone asks about the "X," mention that XML was swapped out for JSON years ago.
Why interviewers ask this
It's a foundational concept — every SPA is built on it. The question filters for people who understand the mechanics of async requests and can translate that into code, not just recite a definition.