The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
Adds custom HTTP headers to the request.
Syntax
var retval = XMLHttpRequest.setRequestHeader(bstrHeader, bstrValue);Parameters
- bstrHeader [in]
-
Type: String
String that specifies the header name.
- bstrValue [in]
-
Type: String
String that specifies the header value.
Return value
Type: HRESULT
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Standards information
- XMLHttpRequest, Section 3.6.2
Remarks
Refer to RFC2616, Section 14: Header Field Definitions for a general list of standard headers. The server is ultimately responsible for honoring the headers of the request. By far the most common request header is Content-Type, which is required by some XML Web services.
setRequestHeader was introduced in Windows Internet Explorer 7.
Examples
The following script sets the HTTP Content-Type header to 'text/xml' before sending the request body:
var oReq = new XMLHttpRequest();
oReq.open("POST", sURL, false);
oReq.setRequestHeader("Content-Type", "text/xml");
oReq.send(sRequestBody);
See also
Send comments about this topic to Microsoft
Build date: 11/29/2012