Simple login (Database not connected)
Copy codeThe Code is 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>
</Head>
<Body>
Username: <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 "Login successful! ";
}
Else {return "Login Failed! ";}
}