jquery

<html>
<head>
    <title>登录页面</title>
</head>

<body>
    <article class="form_content">
        <form>
            <article class="username">
                <label id="labUserName" word="UserName">用户名:</label>
                <input id="txtUserName" type="text" placeholder="用户名" />
            </article>
            <article class="password">
                <label id="labPassword" word="Password">密码:</label>
                <input id="txtPassword" type="password" placeholder="密码" />
            </article>
            <article class="Prompt_text">
                <label id="txteErrMessage"></label>
            </article>
        </form>
        <button id="submit" class="loginConfirm" type="button">立即登录</button>
    </article>


    <!--脚本-->
    <script src="~/js/jquery-1.10.2.min.js"></script>
    <script src="~/js/Home/Home.js"></script>
    <script type="text/javascript">
        jQuery(function($) {
            $.InitPage(); //页面JS加载
        });
    </script>
</body>
</html>
;
(function($, window, document, undefined) {
    $.extend({
        //调用:$.InitPage();
        InitPage: function(options) {

            var param = {
                pageIndex: 1,
                pageSize: 20,
                pageList: [10, 20, 50],

                username: "#txtUserName",
                password: "#txtPassword"
            };
            var settings = $.extend({}, param, options);
            //settings.pageIndex;
            //settings.pageSize;

            //$(settings.username).val(); == $("#txtUserName").val();
            //$(settings.password).val(); == $("#txtPassword").val();


            //登录
            $("#btnLogin").click(function() {
                //请求
                $.ajax({
                    type: "POST",
                    url: "/Home/Login",
                    data: {
                        //参数
                        username: $("#txtUserName").val(),
                        password: $("#txtPassword").val()
                    },
                    dataType: "json",
                    success: function(data) {
                        //请求返回json数据
                        if (data.status) {
                            window.location.href = data.url;
                        } else {
                            alert(data.message);
                        }
                    }
                });
                //end请求
            });
            //end登录

            function BindDDL() {
                $.ajax({
                    type: "GET",
                    url: "Home/GetName",
                    data: {}, //无参数
                    dataType: "json",
                    success: function() {
                        //请求返回json数据
                        if (data.status) {
                            //
                        } else {

                        }
                    }
                });
            };
            BindDDL(); //绑定数据

        }
    });

})(jQuery, window, document);

 

posted @ 2017-10-30 23:30  茗::流  阅读(95)  评论(0)    收藏  举报
如有雷同,纯属参考。如有侵犯你的版权,请联系我。