layer的confirm框,为什么不执行对应的函数呢?

1.会弹出123
2.但是不会弹出1
3.也不会弹出2
4.确认提交confirm框会一闪而过,之后表单提交

 <form method="post" action="<%=basePath%>questionnaire/save"  onsubmit="return check_form()" id="form_1">
</form>
function check_form(){
    alert(123);
    layer.confirm('确认提交?', 

            {
              btn: ['确定','取消'] //按钮

            }, 

            function(index){
                alert(1);
              layer.msg('感谢您参与平台调研,稍后会有工作人员联系您!', {icon: 1});
              return true;
            },
            function(index){
                alert(2);
                layer.msg('已取消!', {icon: 1});
                return false;
            }
        );
}

layer是div模拟的,挂起不了onsubmit事件的执行,在回掉函数里面return 返回也不是check_form的返回值,只是处理函数的返回值

在最后return false阻止表单提交,改为ajax提交


function check_form(){
    alert(123);
    layer.confirm('确认提交?', 

            {
              btn: ['确定','取消'] //按钮

            }, 

            function(index){
                alert(1);
                                ///ajax提交的代码,ajax提交成功再执行西面这句
                                $.ajax({url:'xxx',data:$('#form_1').serialize(),type:'POST',complete:fnction(){
                                  layer.msg('感谢您参与平台调研,稍后会有工作人员联系您!', {icon: 1});
                                })
            /////return true;///不用了,没什么用

            },
            function(index){
                alert(2);
                layer.msg('已取消!', {icon: 1});

            }
        );

                return false;/////////////////////
}

这样写为什么都会执行啊

<!DOCTYPE HTML>
<html>
<head>
        <meta charset="UTF-8">
        <script src="jquery.min.js"></script>
        <script src="layer/layer.js"></script>
</head>
<script>
function check_form(){
    alert(123);
    layer.confirm('确认提交?', 
            {
              btn: ['确定','取消'] //按钮
            }, 
            function(index){
                alert(1);
              layer.msg('感谢您参与平台调研,稍后会有工作人员联系您!', {icon: 1});
              return true;
            },
            function(index){
                alert(2);
                layer.msg('已取消!', {icon: 1});
                return false;
            }
        );
}
</script>
<body>
<form name="testform" action="#" onsubmit="return check_form()">
<input type="submit" value="Submit" />
</form>

</body>
</html>