mvc ajax

来源:互联网 发布:会计网络继续教育考试 编辑:程序博客网 时间:2024/05/24 05:24
    jQuery(document).ready(function () {        // 默认焦点在用户名输入匡        $("#username").focus();        //用户名输入匡输入回车跳转到密码输入匡        $("#username").keyup(function (event) {            if (event.keyCode == 13) {                $("#password").focus();            }        });        //密码匡输入回车执行登陆事件        $("#password").keyup(function (event) {            if (event.keyCode == 13) {                $("#submitLogin").click();            }        });        App.setPage("login_bg");  //Set current page        App.init(); //Initialise plugins and elements    });    var t = 1;    $("#submitLogin").click(function () {        $(this).val("登陆中").prop("disabled", true);        $.ajax({            url: "@Url.Content("~/Home/LoginFrom")",            type: 'post',            html: "json",            data: { username: $('#username').val(), password: $('#password').val() },            success: function (data) {                if (data.Result === 1) {                    $("#loginMsg").hide();                    setTimeout(function () { window.location.href = "@Url.Content("~/Home/Index")" }, 2000);                } else {                    $("#loginMsg").show();                    $("#loginMsg").html(data.Message);                    $("#submitLogin").val("登陆").removeAttr("disabled");                }            }        });    }    );
0 0
原创粉丝点击