开发者

http headers with the help of javascript?

开发者 https://www.devze.com 2022-12-31 21:47 出处:网络
How to se开发者_C百科nd http headers with the help of javascript?Sure. var xhr = new XMLHttpRequest();

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

精彩评论

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