2012-04-02 115 views
0

我想在客户端浏览器请求我写了这个代码:获取浏览器的请求

<script type="text/javascript"> 
    var req = null; try { req = new XMLHttpRequest(); } catch (e) 
{ } if (!req) try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) 
{ } if (!req) try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { } 
req.open('TRACE', 'http://localhost/Xmlobject.aspx', false); 
req.send(); alert(req.responseText); </script> 

,但它有以下错误:

Error: uncaught exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.open]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: http://localhost:7474/xss1/Xmlobject.aspx :: <TOP_LEVEL> :: line 7" data: no] 

我搜索,在谷歌和我发现有人说你不在你的域名中,但我在本地主机。 有什么方法可以获得浏览器响应?

回答

0

the XHR documentation

Throws a "SecurityError" exception if method is a case-insensitive match for CONNECT, TRACE or TRACK.

您不能使用XHR HTTP TRACE请求。