//ajax测试
VAR XMlHtt
p; function createX
MLHtt
PRequest(){
if(window.ActiveXObject){
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest();
}
}
function a(){
createXMLHttpRequest()
url="${request.contextPath}/
test/forM
ain.action";
alert(url);
statechange;
xmlHttp.o
PEn("GET",url,true);
xmlHttp.Send(null);
alert(xmlHttp.responseText);
}
function statechange(){
alert(xmlHttp.status);
if(xmlHttp.readyState
== 4){//描述一种"已加载"状态;此时,响应已经被完全接收。
if(xmlHttp.status == 200){//200表示成功收到
alert("成功");
return xmlHttp.responseText; //返回值
}
else{
alert("失败");
}
}
}