function setPayPwd(){
var mobile=document.getElementById("telPhone").value; var payPassword=document.getElementById("payPwd").value; var rePayPassword=document.getElementById("rePayPwd").value; // alert("mobile="+mobile+"And"+"payPassword="+payPassword); if(payPassword!=rePayPassword){ alert("前后输入的密码不一致,请重新设置!"); $("#payPwd").focus(); return; } alert("密码一致,开始交互"); //前后台交互 $.ajax({ type: "POST", //用POST方式传输 dataType: "json", //数据格式:JSON url: '${path}/member/setPayPwd.shtml', //目标地址 data: {mobile:mobile, payPassword: payPassword}, error: function (XMLHttpRequest, textStatus, errorThrown) { }, success: function (msg){ if(msg.ret !=1){ layer.msg(msg.msg); }else{ layer.msg('验证成功,请设置支付密码!', { time: 1000 //2秒关闭(如果不配置,默认是3秒)}, function(){ window.location.href="${path}/goods/index.shtml";}); } } }); //alert("设置成功!"); }触发此方法的语句;<input type="button" οnclick="setPayPwd()" value="提交" />后台接收代码:@RequestMapping("/setPayPwd")public String setPayPwd(ModelMap mm,String mobile,String payPwd){ JSONObject json = new JSONObject();Map<String, Object> returnMap = new HashMap<String,Object>();if(StringUtil.isBlank(mobile)||StringUtil.isBlank(payPwd)){ json = getJson(0, null, "参数缺失!");}Map<String,String> map = new HashMap<String,String>();map.put("membermobile", mobile);map.put("memberpaypwd", payPwd);returnMap = shopMemberService.login(map);if(returnMap!=null&&((String)returnMap.get("isResult")).equals("0")){ json.put("ret", 1); //0失败 1成功json.put("data", returnMap); //返回数据json.put("msg", "设置成功!"); //返回消息setUser(returnMap); }else{ json = getJson(0, null, (String)returnMap.get("memberMsg"));} mm.put("json",json);return AJAX_RETURN;}欢迎加入WEB前端互动交流群04,海量学习资料免费送