使用jquery 的ajax 怎么提交不到后台去呢,新手上路,请各位大侠帮忙。
<script type="text/javascript" src="<%=path %>/jquery/jquery-1.6.2.min.js"></script><script type="text/javascript">
function checkName(){
var eName = $("#eName").val();
$.ajax({
url:"<%=path %>/jsp/login.do?m=isExist",
success:function(mes){
document.getElementById("nameMsg").value = mes;
}
});


}</script> public ActionForward isExist(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
PrintWriter out = response.getWriter();
int petId = 0;
String isExist = "";
String eName = request.getParameter("eName");
petId = petBo.getPetByName(eName).getId();

if(petId == 0){
out.println("不存在");
}else{
out.println("存在");
} return null;
}

解决方案 »

  1.   

    url:"<%=path %>/jsp/login.do?m=isExist",
    手动访问这个URL 可以访问吗?
      

  2.   

    如果方法都没进入,就是url错啦
      

  3.   

    你的eName没有传到后台去吧,url里面都没有,你却在后台String eName = request.getParameter("eName");这样是取不到滴,struts1没用过
      

  4.   

    url:"<%=path %>/jsp/login.do?m=isExist",
    url这样是取不到滴
      

  5.   

    多谢各位师兄的热心指教,问题现在已经解决了。
    到最后才搞明白,是struts的验证框架拦截了ajax的异步提交,还有就是uName也没有传入到页面上去。