jquery-ui弹框登录前端写法

                新建一个div:

<div class="container" id="loginForm" hidden>
    <h4 class="form-signin-heading">用户登录</h4>
    <hr />
    <div class="form-group">
        <input type="text" class="form-control" id="KeyName" placeholder="Auth Key" name="Key">
    </div>
    <div class="form-group">
        <input type="password" class="form-control" id="Pwd" placeholder="Auth Secret" name="Secret">
    </div>
    <div class="form-group">
        <button class="btn btn-large btn-primary" id="btnLogin" onclick="LoginCheck()">登录</button>
    </div>
</div>

                弹框js写法,可以存放在初始化中:

function showDialogLogin() {
            $("#loginForm").dialog({
                height: 300,
                width: 200,
                // 模态开启  
                modal: true,
                // 是否可拖拽  
                draggable: true,
                // 最小宽度  
                minWidth: 300,
                //当用户按 Esc 键之后,是否应该关闭对话框,默认为 true
                closeOnEscape: true

            });
        }

                       获取值登录:

function LoginCheck() {
        var key = $("#KeyName").val();
        var Secret = $("#Pwd").val();
        var data = { key, Secret }
        $.ajax({
                type: "post",
                dataType: "json",
                url: '/account/Login',
                data: data,
            success: function (res) {
                if (res.Message == "success") {
                    $("#loginForm").dialog('close');
                }
                else {
                    alert("请重新输入");
                }
            },
            error: function () {
                alert("请重新输入");
            },
        });
    };

 

posted @ 2017-03-21 14:46  雪?  阅读(1491)  评论(0编辑  收藏  举报