利用Ajax改变发送请求方式

由于测试的时候需要模拟Head请求,解决办法:先访问要请求的站点,然后在浏览器的控制台下执行如下代码,请求方式就为参数给的值:

var xmlHttp;    
if (window.ActiveXObject) {    
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");    
} else if (window.XMLHttpRequest) {    
    xmlHttp = new XMLHttpRequest();    
}    
 xmlHttp.open("Head","http://localhost:8080/myWebSite/Login.jsp",true);    
 xmlHttp.send(); 

RUN script后,如下图:

 

 

posted @ 2014-01-16 14:04  jenniferhuang  阅读(445)  评论(0编辑  收藏  举报