asp.net+ajax的Post请求实例

2019-05-23 05:05:32于海丽

        $(function () { 
            $("#btnShowLoginDlg").click(function () { 
                $("#divLogin").dialog({ 
                    height: 200, 
                    modal: true 
                }); 
            }); 
            $("#btnLogin").click(function () {  //当用户点击"登陆" 控件触发事件 
                //todo:检验用户名、密码不能为空 
                var username = $("#txtUserName").val(); 
                var password = $("#txtPwd").val(); 
                $.post("/ajax/UserLogin.ashx",//----------------------请关注这条$.Post()请求的参数与回调函数 
                    { "username": username, "password": password }, 
                    loginFinish); 
            }); 
        }); 
 
        $(function () { 
            checkLogin();//刚进入页面的时候也是先向服务器查询当前登录状态 
            $("#btnLogout").click(function () { 
                $.post("/ajax/Logout.ashx", function () { 
                    checkLogin();//刷新显示 
                }); 
            }); 
        }); 
    </script> 
    <asp:ContentPlaceHolder ID="head" runat="server">