zisetoufa 发表于 2013-1-29 08:45:38

jquery ajax提交表单从action传值到jsp

jsp页面:
var clientTel = $("#clientTel").val();var activityId = $("#activityId").val();$.ajax({type : "post",//发送方式 url : "/arweb/reserve/saveCode.action",// 路径data : "clientTel="+clientTel+"&activityId="+activityId ,success: function(text){$("#randomCode").val(text);},error: function(text) {alert("对不起,用户ID不存在,请输入正确的用户ID");}});

action类:
HttpServletResponse res = ServletActionContext.getResponse();res.reset();res.setContentType("text/html;charset=utf-8");PrintWriter pw = res.getWriter();pw.print(random);pw.flush();pw.close();

pw.print(random);这里的random就是action要向jsp传的值,在jsp中,success: function(text)这里的text就是接收从action传过来的值。
页: [1]
查看完整版本: jquery ajax提交表单从action传值到jsp