关于Ajax调用struts1.x中的action的问题

风吹沙散 2009-09-22 08:54:11
用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参数的问题

帮帮忙了,谢谢大家!
...全文
171 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
mianfeidog 2009-09-23
  • 打赏
  • 举报
回复
xmlHttp.open("POST",url,true);
改为 xmlHttp.open("GET",url,true);
看看,我看你传参方式是get的
风吹沙散 2009-09-22
  • 打赏
  • 举报
回复
大虾们,帮帮忙了

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧