日期:2014-05-17  浏览次数:20585 次

AJAX初学者问题xmlHttp.status =404
function startRequest() {
  createXMLHttpRequest();
  var url = "Test01"
  xmlHttp.onreadystatechange = handleStateChange;
  xmlHttp.open("GET", url, true);

  xmlHttp.send(null);

}
   
function handleStateChange() {

  if(xmlHttp.readyState == 4) {
alert(xmlHttp.status );
  if(xmlHttp.status == 200) {
  alert("The server replied with: " + xmlHttp.responseText);
  }
  }
}

Test01是个java类,就打印一句话,我吧url的路径设为同目录下的xml文件 是正常的 ,访问后台就404,路径我改了好几次了什么../../../Test01还是404,请大家指点下问题出在哪里了

------解决方案--------------------
实体类是不能直接访问到的 必须访问servlet,需要在web.xml配置