zoukankan      html  css  js  c++  java
  • 关于layer.alert()函数不调用

    代码:

    var ms = $("input[name='mstj']:checked").val();

    if(ms === '1'){

      layer.alert('请确认您为免试!');

    }

    layer.confirm(
      '您确定要保存当前信息吗?',
      {title:['系统消息','background:#e4f4eb;color:#238651;'], btn: ['确定', '取消'],icon: 3},
      function(index){
        $('#form1').ajaxSubmit({

          type:'post',
          dataType:'json',
          url:'student_util.jsp',
          timeout: 20000,
          success:function(data){
            if(data.state=='1'){
              layer.msg('操作成功!',{icon: 6});
              setTimeout('window.location.href="apply_util.jsp"',1000);//setTimeout是js附带的延缓执行函数
            }else{
              layer.msg('操作失败!',{icon: 5});
            }
          },error:function(req, textStatus, errorThrown){
          alert('操作出现异常,请稍后再试!');
        }
      });
    });

    解决方法

    var ms = $("input[name='mstj']:checked").val();
    if(ms === '1'){
      layer.alert('请确认您为免试!', function(index){
        layer.confirm(
        '您确定要保存当前信息吗?',
        {title:['系统消息','background:#e4f4eb;color:#238651;'], btn: ['确定', '取消'],icon: 3},
          function(index){
            $("#uploadFile").remove();
            checkSubmitFlg = true;
            $('#form1').ajaxSubmit({
              type:'post',
              dataType:'json',
              url:'student_util.jsp',
              timeout: 20000,
              success:function(data){
                if(data.state=='1'){
                layer.msg('操作成功!',{icon: 6});
                setTimeout('window.location.href="apply_util.jsp"',1000);//setTimeout是js附带的延缓执行函数
              }else{
                layer.msg('操作失败!',{icon: 5});
              }
            },error:function(req, textStatus, errorThrown){
              alert('操作出现异常,请稍后再试!');
          }
        });
       });
      });
    }

    原因:

      layui的所有组件都是非阻断式的,所以处理的话一般都在msg的end关闭消息后去处理跳转

  • 相关阅读:
    慕课网-安卓攻城狮视频学习及练习(二)
    慕课网-安卓攻城狮视频学习及练习(一)
    1126 Eulerian Path
    1127 ZigZagging on a Tree
    1128 N Queens Puzzle
    1129 Recommendation System
    1130 Infix Expression
    1131 Subway Map
    1132 Cut Integer
    1133 Splitting A Linked List
  • 原文地址:https://www.cnblogs.com/zying3/p/11097854.html
Copyright © 2011-2022 走看看