The XMLHttpRequest method open() initializes a newly-created request, or re-initializes an existing one.
Note: Calling this method for an already active request (one for which open() has already been called) is the equivalent of calling abort().
Syntax
XMLHttpRequest.open(method, url[, async[, user[, password]]])
Parameters
method- The HTTP request method to use, such as
"GET","POST","PUT","DELETE", etc. Ignored for non-HTTP(S) URLs. url- A
DOMStringrepresenting the URL to send the request to. asyncOptional- An optional Boolean parameter, defaulting to
true, indicating whether or not to perform the operation asynchronously. If this value isfalse, thesend()method does not return until the response is received. Iftrue, notification of a completed transaction is provided using event listeners. This must be true if themultipartattribute istrue, or an exception will be thrown.Note: Synchronous requests on the main thread can be easily disruptive to the user experience and should be avoided; in fact, many browsers have deprecated synchronous XHR support on the main thread entirely. Synchronous requests are permitted in
Workers. userOptional- The optional user name to use for authentication purposes; by default, this is the
nullvalue. passwordOptional- The optional password to use for authentication purposes; by default, this is the
nullvalue.
Specifications
| Specification | Status | Comment |
|---|---|---|
| XMLHttpRequestThe definition of 'open()' in that specification. | Living Standard | WHATWG living standard |
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
open
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox Full support 1 Full support 1 Notes' Starting in Firefox 30, synchronous requests on the main thread have been deprecated due to their negative impact on performance and the user experience. Therefore, the |
IE
Full support 5 |
Opera
Full support 8 |
Safari
Full support 1.2 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android Full support 4 Full support 4 Notes' Starting in Firefox 30, synchronous requests on the main thread have been deprecated due to their negative impact on performance and the user experience. Therefore, the |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
Legend
- Full support
- Full support
- See implementation notes.'
- See implementation notes.
See also
- Using XMLHttpRequest
- Related
XMLHttpRequestmethods:setRequestHeader(),send(), andabort()
XMLHttpRequest.open() by Mozilla Contributors is licensed under CC-BY-SA 2.5.