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 ; }); |
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步