开发者

http headers with the help of javascript?

How to se开发者_C百科nd http headers with the help of javascript?


Sure.

var xhr = new XMLHttpRequest();
xhr.open("POST", "/path/to/script", false);
xhr.setRequestHeader("Content-Type", "text/xml");
xhr.send(strUrlEncodedPostVariables);

Be careful though. IE 5, 5.5 and 6 didn't support the XMLHttpRequest object, so you had to use new ActiveXObject() and the implementation was wonky (but worked). I don't recall how you set headers in the ActiveXObject implementation (I think it was the same), but I remember it did allow it. Strangely, the Wikipedia article on XHR is the easiest place to read up on this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜