复制代码 代码如下:
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传过来的值。