Simple login function (database not connected)
Copy Code code as follows:
<script src= "Jquery1.7.js" type= "Text/javascript" ></script>
<script type= "Text/javascript" >
$ (function () {
$ (' #tijiao '). Click (function () {
var username = $ (' #username '). Val ();
var pwd = $ (' #pwd '). Val ();
$.ajax ({
Type: "Post",
ContentType: "Application/json",
URL: "Webservice1.asmx/denglu",
Data: "{username: '" + username + "', pwd: '" + pwd + "'}",
Success:function (bukeyi) {
$ (' #tishi '). Text (BUKEYI.D);
}
})
})
})
</script>
<body>
User name: <input type= "text" id= "username" runat= "server"/>
Password: <input type= "text" id= "pwd" runat= "Server"/>
<input type= "button" id= "Tijiao" value= "Submit"/>
<div id= "Tishi" ></div>
[WebMethod]
public string Denglu (String username,string pwd)
{
if (username = = "Zhangsan" && pwd = = "123")
{
Return "Landing success! ";
}
else {return] landing failed! "; }
}