//ajax测试 var xmlHttp; function createXMLHttpRequest(){ if(window.ActiveXObject){ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } else if(window.XMLHttpRequest){ xmlHttp=new XMLHttpRequest(); } } function a(){ createXMLHttpRequest() url="${request.contextPath}/test/forMain.action"; alert(url); statechange; xmlHttp.open("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("失败"); } } }