用MyEclipse建的工程
WebRoot下有个common.js文件struts-config.xml中action的配置如下:
<action
      attribute="registryForm"
      input="/users/error.jsp"
      name="registryForm"
      path="/registry"
      scope="request"
      type="weizhiyuan.MyBlog.struts.action.RegistryAction">
   <forward name="success" path="/users/reg_success.jsp" />
</action>common.js中通过XMLHttpRequest的open方法,将请求发送到上面那个action,代码:
var xmlHttp = createXmlHttp();
var url = "/registry.do?username="+nameValue+"&password="+pwdValue+"&password2="+pwd2Value+"&question="+quesValue+"&answer="+ansValue+"&email="+emailValue+"&qq="+qqValue+"&occupation="+occuValue;
//window.alert("xml has bean created!");
window.alert(url);
window.alert(xmlHttp);//这里能打印出来
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

//window.alert("request has been dilevered!");
xmlHttp.onreadystatechange = function(url){
window.alert(xmlHttp.status);
if(xmlHttp.readyState == 1) window.alert("请求提交");//这里无任何反应
if(xmlHttp.readyState == 4){
if(xmlHttp.status == 200){
window.alert("200");
var fd = document.getElementById("fd");
closeed(fd);
window.alert("closed!");
var loginMS = document.getElementById("loginMS");
loginMS.innerHTML = responseText ;
}
}
}
为何请求发送不出去?
经过很多测试,我感觉应该是open方法的那个url参数的问题帮帮忙了,谢谢大家!