標籤:else mobile 目標 bsp pat elm 跳轉 input pos
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" onclick="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,海量學習資料免費送
前後台互動,使用ajax傳輸參數,可是沒有跳轉到背景路徑中