#2
ahjbliss12015-04-03 22:59
|
本人新手一枚,最近遇到一个小问题就是
function httpRequest(reqType,url,async,resFun,paramter){
var request =null;
if(window.XMLHttpRequest){
request = new XMLHttpRequest();
}else if(window.ActiveXObject){
request = new ActiveXObject("Microsoft.XMLHTTP");
}
if(request||typeof(request)=="object"){
if(reqType.toLowerCase()=="post"){
request.open(reqType,url,true);
request.open('post','http://localhost:8081/study/startExam',true);
request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
request.onreadystatechange=resFun;
parameter = encodeURI(paramter);
alert('http://localhost:8081/study/startExam'+parameter);
request.send(parameter);
}else{
url=url+"?"+paramter;
request.open(reqType,url,true);
request.onreadystatechange=resFun;
request.send(null);
}
}else{
alert("brower do not support AJAX!")}
return request;
}
在 request.open('post','http://localhost:8081/study/startExam',true);这块一直没有执行,我alert这段代码后得到undefined
我以为url地址问题,结果window.open(url)也是可以打开的?
为什么啊?不能理解了。打开的就是服务器servlet的地址而已啊怎么会这样子