前後台互動,使用ajax傳輸參數,可是沒有跳轉到背景路徑中

來源:互聯網
上載者:User

標籤: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傳輸參數,可是沒有跳轉到背景路徑中

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.