Fact-checked by Grok 2 weeks ago

XMLHttpRequest

XMLHttpRequest (XHR) is a that provides client-side functionality for transferring data between a and a using HTTP or similar protocols, enabling asynchronous communication without requiring a full page reload. Its name originates from its initial design for handling XML data, though it now supports diverse formats including , text, binary data (such as ArrayBuffer and ), and . Originally developed by in 1999 as an component in the library for enhancing Web Access in 5.0, XMLHttpRequest allowed for dynamic server interactions in web applications. It gained widespread adoption when other browsers like , , and implemented native versions, establishing it as a by the early . In 2006, the (W3C) published the first specification, formalizing the API. The current living standard is maintained by the , incorporating enhancements from XMLHttpRequest Level 2 (introduced in 2008), such as support for (CORS), progress events, timeouts, and file uploads. XMLHttpRequest played a pivotal role in the development of Asynchronous JavaScript and XML (), a technique coined by Jesse James Garrett in 2005 that revolutionized user interfaces by enabling seamless, real-time updates to web pages. Key methods include open() for initializing requests, send() for transmitting data, and abort() for cancellation, while properties like readyState, status, and response facilitate monitoring and handling responses. Although largely superseded by the modern Fetch API for new development, XMLHttpRequest remains widely supported across browsers and is essential for legacy code, Web Workers, and scenarios requiring fine-grained control over HTTP requests.

History and Development

Origins in Microsoft Technology

The XMLHttpRequest technology originated as a proprietary innovation developed in 1999 by engineer Shawn Bracewell as part of the Outlook Web Access (OWA) team for . This component, initially named XMLHTTP, was created to enable asynchronous communication between the web client and the Exchange server, allowing OWA to fetch and update data without requiring full page reloads. The effort was funded by the Exchange team to meet OWA's requirements for dynamic, real-time interactions in a browser-based interface. Microsoft first publicly implemented XMLHTTP as an ActiveX object called "Microsoft.XMLHTTP" in 5.0, released on March 18, 1999. Integrated into the 2.0 library, it provided developers with a programmatic way to send HTTP requests and handle XML responses directly from within . This marked the debut of asynchronous data retrieval in a major browser, laying the groundwork for more responsive web applications. In its early years, XMLHTTP found primary use in enhancing dynamic web experiences, such as updating inboxes or form validations without interrupting the user's view of the page—capabilities that foreshadowed modern single-page applications but predated the widespread adoption of the term "" in 2005. For instance, OWA leveraged it to rewrite its entire interface using (DHTML) techniques, enabling seamless data refreshes that preserved document state on the client. As an ActiveX-based feature, however, it remained exclusive to , limiting its accessibility to developers targeting that browser and hindering broader innovation due to the absence of native equivalents in competitors like . This proprietary status persisted until the mid-2000s, when other browsers began implementing compatible versions, starting with Mozilla's native XMLHttpRequest in around 2000 and gaining momentum with in 2004, which collectively spurred cross-browser support by 2003–2005.

Standardization by W3C and

The transition of XMLHttpRequest from a proprietary Microsoft technology to an open web standard began with independent implementations by other browser vendors, notably , which developed a native version in its engine around 2000, facilitating broader adoption beyond . This effort helped popularize the , prompting formal efforts to ensure across browsers. In 2006, the (W3C) published its initial specification for XMLHttpRequest as part of the Web Applications 1.0 working draft, defining the core for scripted HTTP client functionality. Concurrently, the Web Hypertext Application Technology Working Group () incorporated XMLHttpRequest into its living standard, initially drawing from existing implementations and maintaining it as an evolving specification since 2006. The continued to update the standard, merging enhancements from the W3C's XMLHttpRequest Level 2 draft by the end of 2011, which introduced features like upload progress events and timeout support to improve asynchronous request handling. By 2012, maintenance of the specification returned fully to the as a living standard, ensuring ongoing compatibility with evolving web platforms. Browser adoption accelerated during this period, with key milestones including support in 1.0 (November 2004), 1.2 (April 2004), Opera 8.0 (April 2005), and full implementation in (October 2006), enabling widespread use of the standardized API. The specification defines the XMLHttpRequest interface using Web IDL, inheriting from XMLHttpRequestEventTarget and exposing methods such as open(), send(), and abort(), along with attributes like readyState, status, and response, to facilitate integration with the (DOM) for dynamic web applications. This IDL-based definition ensures the API's exposure on the object and in worker contexts, aligning it with broader DOM standards for consistent scripting behavior across environments.

Core Functionality

Object Creation and Properties

The XMLHttpRequest object is instantiated in modern web browsers using the constructor new XMLHttpRequest(), which creates a new instance and initializes it with an associated XMLHttpRequestUpload object for upload progress tracking. In legacy versions of (prior to version 7), compatibility required falling back to ActiveXObject creation, such as new ActiveXObject("Microsoft.XMLHTTP") or new ActiveXObject("Msxml2.XMLHTTP") for later versions, to ensure cross-browser support in older environments. Core properties of the XMLHttpRequest object manage its state, response data, and configuration. The readyState property, a read-only unsigned short, indicates the current phase of the request lifecycle with discrete values: 0 for UNSENT (object just constructed), 1 for OPENED (after open() invocation), 2 for HEADERS_RECEIVED (response headers available), 3 for LOADING (response body downloading), and 4 for DONE (operation complete, successful or failed). The status property, also read-only and an unsigned short, holds the HTTP response status code from the server, such as 200 for success or 404 for not found, while statusText provides the corresponding textual message as a read-only ByteString, like "OK" or "Not Found". For response content, the responseType property is a DOMString that specifies the type of response expected, with possible values: the empty string (default, equivalent to "text"), "arraybuffer", "blob", "document", "json", or "text". The read-only response property then returns the response in the corresponding format: a USVString for "text" or empty, ArrayBuffer for "arraybuffer", Blob for "blob", Document for "document", or parsed JSON for "json"; it is null if the type is unsupported or the request failed. Additionally, responseText returns the raw response as a read-only USVString when responseType is empty or "text", and responseXML parses it as a read-only Document object if responseType is empty or "document", enabling XML manipulation. Request configuration properties include timeout, an unsigned long that sets the maximum time in milliseconds before the request aborts (default 0 for no timeout), which throws an "InvalidAccessError" if set during synchronous requests in contexts. The open() method initializes the request with parameters: a required ByteString (e.g., "GET" or "POST"), a required USVString , an optional for asynchronous mode (true by default), and optional USVString username and password for . Custom headers are added via setRequestHeader(name, value), where both arguments are ByteStrings; this appends to existing headers but throws "InvalidStateError" if the readyState is not OPENED or if the request has already been sent. Event handling for state changes is facilitated by the onreadystatechange property, an event handler that fires whenever readyState updates (except from UNSENT), allowing developers to monitor progress without deeper event system integration.

Methods for Request Management

The open() method initializes a new request, specifying the HTTP method, target URL, and other parameters to prepare the XMLHttpRequest object for transmission. It takes five parameters: the HTTP method as a ByteString (e.g., "GET", "POST"), the request URL as a USVString, an optional boolean for asynchronous mode (defaulting to true), and optional username and password for authentication as USVStrings. Upon invocation, it terminates any ongoing fetch, sets the object's ready state to 1 (OPENED), and may throw exceptions such as SyntaxError for invalid inputs, SecurityError for forbidden methods like CONNECT in certain contexts, or InvalidAccessError if synchronous requests are restricted. The send() method transmits the prepared request to the , optionally including a request body for methods like POST or PUT. It accepts a single optional parameter for the body, which can be null (default), a , a , a , or other XMLHttpRequestBodyInit types, though bodies are ignored for GET and HEAD requests. This method can only be called when the ready state is 1 (OPENED) and no prior request has been sent; otherwise, it throws an InvalidStateError. Invoking send() initiates the fetch process, updating the ready state to 2 (HEADERS_RECEIVED) upon receiving headers and 3 (LOADING) as the body loads, or 4 (DONE) upon completion. To cancel an ongoing request, the abort() method can be used, which immediately halts any network activity associated with the XMLHttpRequest object. It requires no parameters and returns undefined, triggering the abort steps that reset the ready state to 0 () and dispatch an abort event if the request was active. This method is particularly useful for user-initiated cancellations or resource management in asynchronous operations. The overrideMimeType() method allows developers to force a specific MIME type interpretation for the response, overriding the server's declared type. It takes a single DOMString parameter specifying the desired MIME type (e.g., "text/plain" or "application/") and must be called before the request is sent, throwing an InvalidStateError if the ready state is 3 (LOADING) or 4 (DONE). If the provided MIME type is invalid, it defaults to "application/octet-stream"; this does not alter the actual response headers but affects how the responseText or response properties are parsed. For accessing response metadata after the request completes, XMLHttpRequest provides getAllResponseHeaders() and getResponseHeader() methods, introduced in Level 2 of the specification. The getAllResponseHeaders() method returns a ByteString containing all response headers as a single, newline-separated string (e.g., "Content-Type: text/html\r\nContent-Length: 123"), with headers sorted alphabetically and combined per the Fetch Standard's filtering rules; it returns null if no headers are available or the ready state is not 4 (DONE). Meanwhile, getResponseHeader(name) retrieves the value of a specific header by ByteString name (case-insensitive), returning a ByteString or null if absent, also adhering to Fetch Standard filters that exclude forbidden headers like Set-Cookie. These methods enable programmatic inspection of server responses without relying on full body parsing.

Request and Response Handling

Configuring and Sending Requests

To configure and send an XMLHttpRequest, the process begins with creating an instance of the XMLHttpRequest object using the constructor new XMLHttpRequest(). This object provides the interface for initiating HTTP requests from JavaScript in web browsers. The next step is to initialize the request by calling the open() method, which specifies the HTTP method (such as "GET" or "POST"), the target URL, and an optional asynchronous flag. The method signature is open(method, url [, async [, username [, password]]]), where the async parameter defaults to true for non-blocking operation; if set to false, the request operates in synchronous mode. For example, xhr.open("GET", "https://example.com/api/data", true); prepares a GET request to the specified endpoint asynchronously. This method must be invoked before setting headers or sending the request, and it throws exceptions for invalid inputs, such as malformed URLs or forbidden methods like CONNECT. Optional custom headers can then be added using the setRequestHeader(name, value) method, which appends or overrides headers after open() but before send(). For instance, xhr.setRequestHeader("Content-Type", "application/[json](/page/JSON)"); sets the content type for a JSON payload. This method enforces restrictions, throwing errors for invalid header names or values, and cannot be called once the request has been sent. The request is dispatched by invoking the send(body) method, where body is an optional parameter that can be null, a string, a , FormData, or other supported types; for methods like GET or HEAD, the body is ignored. In asynchronous mode (the default), send() returns immediately, allowing the script to continue execution while the request processes in the background. Conversely, synchronous mode (async = false) blocks the calling thread until the response is received, enabling direct access to response properties immediately after send(), but this is deprecated in main browser contexts due to its potential to freeze the . For handling request bodies, GET requests typically encode parameters directly in the URL (e.g., via query strings like ?key=value), while POST or PUT requests pass data through the send() body. Common approaches include URL-encoding form data as a string, using FormData for multipart/form-data submissions, or serializing objects with JSON.stringify() for JSON payloads, often paired with the appropriate Content-Type header. Best practices emphasize using asynchronous mode exclusively in user-facing contexts to prevent UI blocking, as synchronous requests are deprecated and restricted in the main thread but allowed in web workers and trigger deprecation warnings in tools. For authenticated requests, set the withCredentials property to true before open() to include credentials like or headers in cross-origin scenarios, provided the server supports it. Additionally, to avoid caching issues with GET requests, append a unique parameter such as a to the .

Processing Responses and Error Handling

Once the XMLHttpRequest object has completed its request, developers can access the response data through specific properties. The responseText property returns the response body as a string, suitable for plain text or data, but it throws an "InvalidStateError" if the responseType is set to anything other than "" or "text". For responses, this string must be parsed using the JSON.parse() method to convert it into a JavaScript object, enabling further manipulation of the data. The responseXML property provides the response as a object if the content is XML or , allowing direct DOM traversal; otherwise, it returns null, and developers may need to use the DOMParser to parse non-XML strings into a for processing. Progress monitoring during and after the request relies on the readyState property, which indicates the current phase: 0 (UNSENT), 1 (OPENED), 2 (HEADERS_RECEIVED), 3 (LOADING), or 4 (DONE). The onreadystatechange event handler is triggered whenever readyState changes, allowing developers to check for completion by verifying if readyState equals 4 and the HTTP status is in the 200-299 range, which signifies a successful response. For asynchronous requests, additional Level 2 event handlers provide more granular control: onload fires upon successful completion, onprogress reports upload/download progress via the ProgressEvent interface, onloadstart signals the start of the request, and onloadend indicates the end regardless of outcome. Error detection involves examining the status property and relevant events. Network errors, such as connection failures, result in a status of 0 and trigger the onerror event, where the response property is set to a network error value. HTTP client errors (4xx) or server errors (5xx) are identified via the status code after readyState reaches 4, with statusText providing the corresponding message. Timeouts are managed by setting the timeout property to a millisecond value before sending the request; if exceeded, the ontimeout event fires, and the request is aborted automatically. The onerror event also handles general failures, including aborts initiated by the abort() method, which sets readyState to 0 and triggers an "AbortError". Common pitfalls in response processing include handling empty responses, where responseText or responseXML may be empty strings or null even on successful statuses, requiring explicit checks before to avoid errors. Charset mismatches can occur if the server's content-type header specifies an encoding not matching the response data, leading to garbled responseText; this is mitigated by using the overrideMimeType() method to force a specific type and charset before sending. Abort-induced errors from calling abort() during an ongoing request must be distinguished from true failures, as they intentionally terminate the operation without populating response properties, often necessitating cleanup in the onabort handler.

Security and Access Controls

Same-Origin Policy Restrictions

The same-origin policy is a fundamental mechanism implemented by web browsers to restrict interactions between from different origins. An origin is defined by the combination of a URL's (such as HTTP or ), host (), and port number (if specified); two resources share the same origin only if all three components match exactly. For instance, requests from https://example.com:443 cannot access resources from http://example.com due to the protocol mismatch or from https://sub.example.com due to the differing host. In the context of XMLHttpRequest, browsers enforce the by preventing cross-origin requests from being initiated or by blocking to their responses. When a attempts to send an XMLHttpRequest to a different origin without explicit permission (such as via CORS), the browser may allow the network transmission for simple methods like GET or POST but prohibits from reading the response data, often throwing a security exception when attempting to like responseText or responseXML. This enforcement isolates potentially malicious , ensuring they cannot exfiltrate sensitive data from other sites. The originated in 1995 with the release of 2.0, coinciding with the introduction of to prevent scripts from one document from accessing properties of another across origins. It was applied to early implementations of XMLHttpRequest, first introduced by in in 1999, to extend these protections to asynchronous HTTP requests and maintain consistent security boundaries as web applications evolved. This policy has significant implications for web applications: it safeguards against data exfiltration by blocking unauthorized cross-origin data access. While it limits attacker feedback in attacks like cross-site request forgery (CSRF) by preventing reading of responses, it does not prevent the sending of forged requests using user credentials; CSRF requires additional mitigations such as tokens. However, it also limits legitimate use cases, such as mashups that aggregate content from multiple domains, by restricting seamless data integration unless workarounds are employed. An exception exists for subdomains, where the deprecated document.domain property can be set to a common parent domain (e.g., from sub.example.com to example.com) on both pages to relax the policy and enable cross-subdomain communication, though this must be mutually configured and does not override protocol or port differences. However, as of 2023, the setter for document.domain has been disabled in major browsers including Chrome and Edge, rendering this exception non-functional; alternatives like the postMessage API should be used for cross-subdomain communication. Developers can detect blocked cross-origin attempts with XMLHttpRequest when the readyState reaches 4 (indicating completion) but the status is 0, signaling a network error or policy violation rather than a valid HTTP response code.

Enabling Cross-Origin Requests with CORS

Cross-Origin Resource Sharing (CORS) is a mechanism that enables web browsers to perform controlled cross-origin HTTP requests, including those made via XMLHttpRequest, by allowing servers to specify which origins are permitted to access their resources. Defined as a W3C Recommendation on January 16, 2014, CORS relies on a set of HTTP headers exchanged between the client and server to relax the same-origin policy restrictions that otherwise block such requests. This standard facilitates secure data exchange in modern web applications, such as loading APIs from different domains, without compromising browser security. For simple requests—such as GET or with standard headers and no custom content types—the sends the request directly, and the server responds with headers indicating permission. However, for non-simple requests, which include methods like PUT or DELETE, or those with custom headers or non-standard content types (e.g., application/json), the first issues a preflight request using the OPTIONS method. This preflight checks if the actual request is allowed by querying the server for supported methods, headers, and origins, preventing potentially unsafe operations from proceeding. The preflight is transparent to code using XMLHttpRequest, as the handles it automatically before the main request. On the client side, developers can configure XMLHttpRequest to include credentials like cookies or HTTP authentication by setting the withCredentials property to true before sending the request. For example:
javascript
var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://api.example.com/data');
xhr.withCredentials = true;
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify({key: 'value'}));
This enables the request to carry user credentials across origins, but it requires the server to explicitly allow credentials via additional headers. Without withCredentials, the request remains anonymous and excludes sensitive data. The XMLHttpRequest flow integrates seamlessly with CORS, where the browser enforces the policy and exposes the response only if the server approves. Server-side implementation is crucial for enabling CORS, requiring responses to include specific headers. The Access-Control-Allow-Origin header specifies permitted origins, such as * for any origin (not recommended with credentials) or a specific domain like https://example.com. For preflight responses, servers must also set Access-Control-Allow-Methods (e.g., GET, POST, PUT) and Access-Control-Allow-Headers (e.g., Content-Type, [Authorization](/page/Authorization)) to match the client's intent. If credentials are involved, the Access-Control-Allow-Credentials: true header is added, but this prohibits wildcard origins in Access-Control-Allow-Origin. For instance, a server might respond to a preflight with:
Access-Control-Allow-Origin: https://client.example.com
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Credentials: true
These headers must be present in both preflight and actual responses for the request to succeed. Despite its flexibility, CORS has limitations when used with XMLHttpRequest. Browsers block access to response data from cross-origin requests unless the server includes the necessary Access-Control-Allow-Origin header, preventing unauthorized reads even if the request is sent. Credentialed requests (with withCredentials: true) are further restricted: they cannot use the wildcard * for origins and must match exactly, enhancing security but requiring precise configuration. Additionally, CORS does not support reading certain response headers without explicit exposure via Access-Control-Expose-Headers, limiting what client code can inspect. These constraints ensure that cross-origin access remains opt-in and controlled by the resource owner.

Alternatives to XMLHttpRequest

Introduction to the Fetch API

The Fetch API, defined in the Fetch Standard, provides a modern interface for fetching resources across the network in web browsers, serving as a unified architecture for HTTP requests, responses, and related processes. Introduced as part of the evolving web platform standards around 2015, it exposes a global fetch() function that initiates network requests and returns a resolving to a Response object, enabling asynchronous handling without the event-driven complexity of earlier methods. This standard ensures consistency in fetching behaviors across various web APIs, such as those used in elements and modules. At its core, the Fetch API uses the syntax fetch(resource, init), where the first argument is the URL or Request object to fetch, and the optional init parameter is an object configuring the request details. Key options in init include method (e.g., 'GET' or 'POST'), headers (a Headers object for custom headers), body (data to send, such as FormData or JSON strings), credentials (to include cookies or not, like 'include' or 'same-origin'), and mode (controlling CORS behavior, such as 'cors' for cross-origin requests with restrictions). These options allow developers to tailor requests flexibly while adhering to web security models. Compared to XMLHttpRequest, the Fetch API offers several advantages, including native support for , which integrates seamlessly with async/await for cleaner asynchronous code, and the ability to stream response bodies via ReadableStream for efficient handling of large payloads. Error handling is simplified, as network failures reject the Promise, though HTTP errors (like ) do not, avoiding the need to track states like readyState. Key differences include the absence of a synchronous mode—Fetch is strictly asynchronous—and built-in methods like response.json() for automatic parsing, alongside support for AbortController and AbortSignal to cancel ongoing requests programmatically. Browser support for the Fetch API is robust in modern environments, with full implementation in 42 and later (released April 2015), 39 and later (July 2015), 10.1 and later (March 2017), and 14 and later (August 2016). For older browsers, polyfills such as whatwg-fetch can provide compatibility by implementing the Promise-based interface.

Comparison of Capabilities and Performance

The Fetch API and XMLHttpRequest (XHR) differ in their core capabilities, with Fetch providing a more modern, promise-based interface that supports advanced features like streaming responses via ReadableStream, enabling efficient handling of large payloads without buffering the entire response in memory. In contrast, XHR natively supports progress events for both uploads (via XMLHttpRequestUpload) and downloads (via onprogress), allowing straightforward monitoring of request advancement, a feature that Fetch lacks in its basic form and requires custom implementation using streams for download progress or falling back to XHR for uploads. Additionally, XHR includes built-in XML parsing through the responseXML property, returning a parsed object, whereas Fetch delivers raw Response objects that necessitate manual parsing for XML or other formats. In terms of usability, Fetch mitigates the "callback hell" associated with XHR's event-driven model—where multiple onreadystatechange handlers must manage state changes—by leveraging native promises and async/await syntax for cleaner chaining and error handling via .catch(). This makes Fetch preferable for contemporary development in ES6+ environments. However, XHR offers broader legacy browser support, functioning reliably in and earlier without polyfills, while Fetch requires shims like whatwg-fetch for such compatibility. Both APIs handle CORS identically, relying on server-side headers for cross-origin permissions, so migration does not alter security configurations. Performance between the two is generally comparable in terms of network latency, as both utilize the underlying HTTP stack, but subtle differences emerge in processing overhead. Benchmarks indicate that Fetch can be marginally faster for parsing in some browsers due to its promise-based offloading, potentially reducing perceived latency by around 100ms for large payloads, though results vary: XHR outperforms Fetch in (7.29 ops/sec vs. 5.25 ops/sec for large fetches) while Fetch leads in (9.99 ops/sec vs. 8.84 ops/sec). XHR's progress tracking is unavailable in basic Fetch implementations, potentially impacting in file scenarios without additional streaming logic. For migration, developers can replace XHR's open() and send() methods with fetch(url, { method: 'POST', body: data }), substituting onreadystatechange logic with .then(response => response.json()).then(data => process(data)).catch(error => handleError(error)) to maintain asynchronous flow. XHR remains suitable for applications requiring precise upload monitoring or targeting pre-ES6 browsers like IE11, whereas Fetch is ideal for new projects benefiting from its extensibility, such as integration with Service Workers for request interception.

References

  1. [1]
    XMLHttpRequest Standard
    Aug 18, 2025 · The XMLHttpRequest Standard defines an API that provides scripted client functionality for transferring data between a client and a server.
  2. [2]
    XMLHttpRequest - Web APIs | MDN
    ### Summary of XMLHttpRequest API
  3. [3]
    Browser APIs and Protocols: XMLHttpRequest
    The official W3C CORS specification defines when and where a preflight request must be used: "simple" requests can skip it, but there are a variety of ...
  4. [4]
    XMLHttpRequest Level 1 - W3C
    Oct 6, 2016 · The XMLHttpRequest specification defines an API that provides scripted client functionality for transferring data between a client and a server.
  5. [5]
  6. [6]
    [PDF] Developing Future Web Application with AJAX and ASP.NET Project ...
    XMLHttpRequest. Invented by Microsoft, First implement in IE5 as. ActiveX (MSXML2). Asynchronous Processing. Allows to kick off an HTTP request in the ...
  7. [7]
    The XMLHttpRequest Object - W3C
    Sep 27, 2006 · This specification defines the XMLHttpRequest object, an API that provides additional HTTP client functionality for transferring data between a ...
  8. [8]
    XMLHttpRequest Level 2 - W3C
    XMLHttpRequest Level 2 enhances XMLHttpRequest with new features, such as cross-site requests, progress events, and the handling of byte ...Missing: 2014 | Show results with:2014
  9. [9]
  10. [10]
  11. [11]
  12. [12]
  13. [13]
  14. [14]
  15. [15]
  16. [16]
  17. [17]
  18. [18]
  19. [19]
  20. [20]
    XMLHttpRequest: send() method - Web APIs | MDN
    Jun 23, 2025 · The XMLHttpRequest method send() sends the request to the server. If the request is asynchronous (which is the default), this method returns as soon as the ...
  21. [21]
  22. [22]
    Synchronous and asynchronous requests - Web APIs | MDN
    Sep 18, 2025 · XMLHttpRequest supports both synchronous and asynchronous communications. In general, however, asynchronous requests should be preferred to synchronous ...Missing: comparison | Show results with:comparison
  23. [23]
    Using XMLHttpRequest - Web APIs | MDN
    Oct 30, 2025 · Cross-site XMLHttpRequest. Modern browsers support cross-site requests by implementing the Cross-Origin Resource Sharing (CORS) standard.
  24. [24]
  25. [25]
    XMLHttpRequest: withCredentials property - Web APIs | MDN
    Jun 24, 2025 · Setting withCredentials has no effect on same-origin requests. In addition, this flag is also used to indicate when cookies are to be ignored in ...Missing: enforcement | Show results with:enforcement<|separator|>
  26. [26]
  27. [27]
  28. [28]
  29. [29]
  30. [30]
  31. [31]
  32. [32]
  33. [33]
  34. [34]
  35. [35]
  36. [36]
    Same-origin policy - Security - MDN Web Docs - Mozilla
    Sep 26, 2025 · Definition of an origin. Two URLs have the same origin if the protocol, port (if specified), and host are the same for both. You may see this ...
  37. [37]
    Same Origin Policy - Web Security
    Jan 6, 2010 · The same-origin policy restricts which network messages one origin can send to another. For example, the same-origin policy allows inter-origin HTTP requests.General Principles · Network Access · Details
  38. [38]
    Definitive Guide to Same-origin Policy (SOP) - Invicti
    In the browsers except IE, the items that define origin are schema/protocol + domain + port; whereas in IE, the port is not involved when defining origin. This ...
  39. [39]
  40. [40]
    Preflight request - Glossary - MDN Web Docs
    Jul 11, 2025 · A CORS preflight request is a CORS request that checks to see if the CORS protocol is understood and a server is aware using specific methods and headers.
  41. [41]
    Fetch Standard - whatwg
    Oct 10, 2025 · The Fetch Standard provides a unified architecture for these features so they are all consistent when it comes to various aspects of fetching.
  42. [42]
    Fetch API - MDN Web Docs
    Apr 9, 2025 · The Fetch API provides an interface for fetching resources (including across the network). It is a more powerful and flexible replacement for XMLHttpRequest.Using Fetch · Window: fetch() method · WorkerGlobalScope.fetch() · RequestMissing: WHATWG | Show results with:WHATWG
  43. [43]
    Window: fetch() method - Web APIs | MDN
    Aug 24, 2025 · The fetch() method starts fetching a resource, returning a promise that resolves to a Response object when the response is available.
  44. [44]
    Using the Fetch API - MDN Web Docs
    Aug 20, 2025 · The Fetch API is a JavaScript interface for making HTTP requests and processing responses. It uses `fetch()` with a URL and returns a promise.Request · Headers · Response · WorkerGlobalScope.fetch()
  45. [45]
    Fetch | Can I use... Support tables for HTML5, CSS3, etc - CanIUse
    "Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
  46. [46]
    Fetch streams are great, but not for measuring upload/download ...
    Sep 15, 2025 · Upload and download progress is unfortunately a missing feature in fetch. If you want progress events today, the best way is to use XHR: const ...
  47. [47]
    XMLHttpRequest API - MDN Web Docs
    Aug 26, 2025 · The XMLHttpRequest API enables web apps to make HTTP requests to web servers and receive the responses programmatically using JavaScript.Using XMLHttpRequest · HTML in XMLHttpRequest · Using FormData Objects<|separator|>
  48. [48]
    The Fetch API performance vs. XHR in vanilla JS - Go Make Things
    Feb 20, 2020 · The Fetch API might be faster than XHR # ... Because XHR has been around for so long, I expected that browsers would be better optimized for it ...
  49. [49]
    window.fetch() vs. XMLHttpRequest benchmark - GitHub
    Whether plain XMLHttpRequest or window. fetch() is faster depends on the browser. Using Firefox, fetch() wins, whereas in Chrome XHR wins. The relative ...
  50. [50]
    Fetch: Download progress - The Modern JavaScript Tutorial
    Jun 22, 2021 · To track download progress, we can use response.body property. It's a ReadableStream – a special object that provides body chunk-by-chunk, as it comes.<|separator|>