AJAX
AJAX (Asynchronous JavaScript and XML) is a technique for building web applications that lets a page exchange data with the server in the background, without reloading the whole page. As a result, the interface can update only a selected part of the view, giving smoother and faster behavior close to that of desktop applications.
How AJAX works
At the heart of the technique is an asynchronous request sent by JavaScript (formerly the XMLHttpRequest object, today more often the modern Fetch API). When a user performs an action — for example types a phrase into a suggestions search — the script sends a request to the server in the background and waits for the response without blocking the interface. The server returns data, today usually in JSON format (despite the X for XML in the name, XML is now rarely used), and JavaScript updates the relevant part of the page in the DOM.
Communication usually takes place with a server-side API, often built in the REST architecture. Asynchronicity is key: the user can keep using the page while the data loads in the background.
AJAX in practice
AJAX powers many everyday features: search suggestions, loading more list items on scroll, form validation without a reload, and updating a shopping cart in a store. It is also the foundation of single-page applications (SPAs), in which all navigation happens without a full page reload. Because content loaded by scripts can be harder to index, sites that rely heavily on AJAX should ensure key content is available to search engine crawlers, for example through server-side rendering. Handling network errors, showing loading states, and securing API endpoints against unauthorized access are equally important when applying it.
Powiązane pojęcia
Najczęstsze pytania
Is AJAX a separate programming language?
No. AJAX is a technique that combines existing technologies: JavaScript to handle requests, a data format (today most often JSON), and a mechanism for asynchronous communication with the server. It is not a standalone language or library.
How does AJAX affect SEO?
Content loaded via AJAX can be harder to index if it appears only after scripts run. That is why key content should be rendered server-side or otherwise made available in a way accessible to search engine crawlers.
