XHRs
XMLHttpRequest (XHR) is a browser API that enables a web page to send HTTP requests to a server and receive responses without reloading the page. It supports asynchronous requests, which allow dynamic updates, and historically also synchronous requests, though the latter are discouraged in modern code. An XHR instance is created with new XMLHttpRequest(), then configured with open(method, URL, async, user, password). The send(body) method transmits the request, and headers can be customized with setRequestHeader.
The server response is exposed through properties such as readyState, status, statusText, responseText, and responseXML. If
XHR is subject to the same-origin policy, meaning requests to other origins are restricted unless the server
In modern development, the Fetch API is often preferred because it uses Promises and provides a simpler,