XMLHttpRequest: XMLHttpRequest() constructor
BaselineWidely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Note: This feature is available inWeb Workers, except forService Workers.
TheXMLHttpRequest()
constructorcreates a newXMLHttpRequest
.
Syntax
new XMLHttpRequest()// Non-standardnew XMLHttpRequest(options)
Parameters
There are no standard parameters. However, Firefox allows a non-standard parameter:
options
Non-standardAn object that can contain the following flags:
mozAnon
A boolean. When setting this flag to
true
will cause the browser not to expose theorigin and user credentials when fetching resources. Most important, this means thatcookies will not be sent unless explicitly added usingsetRequestHeader
.mozSystem
A boolean. When setting this flag to
true
, the same origin policy will not be enforced on the request.
Return value
A newXMLHttpRequest
object. The object must be prepared by at leastcallingopen()
to initialize it before callingsend()
to send the request to the server.
Specifications
Specification |
---|
XMLHttpRequest # dom-xmlhttprequest |