--- title: XMLHttpRequest.open() slug: Web/API/XMLHttpRequest/open tags: - Reference - XMLHttpRequest translation_of: Web/API/XMLHttpRequest/open ---
{{APIRef('XMLHttpRequest')}}
XMLHttpRequest.open() 方法初始化一个请求。该方法要从JavaScript代码使用;从原生代码初始化一个请求,使用openRequest()替代。
open()或openRequest()已被调用)相当于调用abort()。xhrReq.open(method, url); xhrReq.open(method, url, async); xhrReq.open(method, url, async, user); xhrReq.open(method, url, async, user, password);
methodurlasync {{optional_inline}}true。如果值为false,send()方法直到收到答复前不会返回。如果true,已完成事务的通知可供事件监听器使用。如果multipart属性为true则这个必须为true,否则将引发异常。
user {{optional_inline}}null。password {{optional_inline}}null。| Specification | Status | Comment |
|---|---|---|
| {{SpecName('XMLHttpRequest', '#the-open()-method', 'open()')}} | {{Spec2('XMLHttpRequest')}} | WHATWG living standard |