aspx调用webmethod

[WebMethod]
       public static string CheckLogin(string user, string pwd)
       {
           pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, "md5");
           University.BLL.Student bll = new University.BLL.Student();
           DataSet ds = bll.Login(user, pwd);
           if (ds.Tables[0].Rows.Count > 0)
           {
               //login成功
               return "登陆成功。";             
           }
           else
           {
               //login失败
               return "登陆失败。";
           }
       }

  

$("#login").click(function () {
               $.ajax({
                   type: "Post",
                   url: "index_Student.aspx/CheckLogin",
                   data: "{ 'user': '" + $("#user").val() + "', 'pwd':'" + $("#pwd").val() + "'}",
                   contentType: "application/json; charset=utf-8",
                   dataType: "json",
                   success: function (data) {
                       //返回的数据用data.d获取内容  
                       alert(data.d);
                   },
                   error: function (err) {
                       alert(err);
                   }
               });
               return false;
 
           });

  

posted @   yuking  阅读(380)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示