XMLHttpRequest

abbreviation XHR

XML Http Request

XMLHttpRequest (XHR) is a JavaScript API that allows web pages to request data from a server asynchronously. It enables dynamic content updates, such as loading new data or submitting forms, without refreshing the entire page.

XHR works by creating a request object, defining the HTTP method (GET, POST, etc.), and specifying the URL of the server endpoint. The server responds with data, which the browser processes and updates the page accordingly. Modern browsers support XHR natively, and it’s commonly used in AJAX (Asynchronous JavaScript and XML) applications.

For developers, XHR changes how web applications interact with servers. It allows for smoother, faster user experiences by reducing page reloads. However, it requires careful handling of errors and security considerations, such as cross-origin requests (CORS). For example, a news website might use XHR to load new articles in the background while the user reads, improving performance and reducing wait times.

When you like a post on social media, the page updates instantly using XHR instead of reloading.

Découvrez nos autres services

ElpisIA, c’est tout un univers — explorez nos autres services.