使用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;
}
<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;
}
手动访问这个URL 可以访问吗?
url这样是取不到滴
到最后才搞明白,是struts的验证框架拦截了ajax的异步提交,还有就是uName也没有传入到页面上去。