www.fgks.org   »   [go: up one dir, main page]

Click to Rate and Give Feedback
Methods
 setRequestHeader Method
setRequestHeader Method

Adds custom HTTP headers to the request.

Syntax

XMLHttpRequest.setRequestHeader(sName, sValue)

Parameters

sName Required. String that specifies the header name.
sValue Required. String that specifies the header value.

Return Value

No return value.

Remarks

Refer to RFC 2616, Section 14: Header Field Definitions World Wide Web link 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.

Example

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);

Standards Information

This method is defined in The XMLHttpRequest Object (W3C Working Draft) World Wide Web link.

Applies To

XMLHttpRequest

See Also

getResponseHeader
Tags What's this?: test (x) Add a tag
Community Content
 
Add Community Content
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker
DCSIMG