XMLHttpRequest()
The XMLHttpRequest() constructor creates a new XMLHttpRequest.
For details about how to use XMLHttpRequest, see Using XMLHttpRequest.
Syntax
const request = new XMLHttpRequest();
Parameters
None.
Return value
A new XMLHttpRequest object. The object must be prepared by at least calling open() to initialize it before calling send() to send the request to the server.
Non-standard Firefox syntax
Firefox 16 added a non-standard parameter to the constructor that can enable anonymous mode (see bug 692677). Setting the mozAnon flag to true effectively resembles the AnonXMLHttpRequest() constructor described in older versions of the XMLHttpRequest specification.
const request = new XMLHttpRequest(paramsDictionary);
Parameters (non-standard)
objParameters-
One flag you can set:
mozAnon-
Boolean: Setting this flag to
truewill cause the browser not to expose the origin and user credentials when fetching resources. Most important, this means that cookies will not be sent unless explicitly added using setRequestHeader.
Specifications
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
XMLHttpRequest |
1 |
12 |
1 |
7 |
≤12.1 |
3 |
1 |
18 |
4 |
≤12.1 |
1 |
1.0 |
See also
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/XMLHttpRequest