XMLHttpRequest()

翻譯不完整。 請幫助我們翻譯這篇文章!

編撰中
本頁仍未完成

XMLHttpRequest() 建構式會建立一個新的 XMLHttpRequest 物件。

關於如何使用 XMLHttpRequest 物件的細節,請參照: Using XMLHttpRequest.

語法

const request = new XMLHttpRequest();

參數

無。

回傳值 

將回傳一個新的 XMLHttpRequest 物件。XMLHttpRequest 物件在呼叫send() 送出要求到伺服器之前,至少要藉著呼叫 open() 來準備好必需的設定。

非標準的 Firefox 語法

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
There are two flags you can set:
mozAnon
Boolean: Setting this flag to true will 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.
mozSystem
Boolean: Setting this flag to true allows making cross-site connections without requiring the server to opt-in using CORS. Requires setting mozAnon: true, i.e. this can't be combined with sending cookies or other user credentials. This only works in privileged (reviewed) apps (bug 692677); it does not work on arbitrary webpages loaded in Firefox

參見