Use jquery to invoke webservice of other projects
Implementing logon Verification Features
HTML Enter user name password:
Code
Copy Code code as follows:
<table style= "width:400px" >
<tr>
<td style= "width: 200px "class=" >
Login ID:
</td>
<td style= "width:200px" class= "left" >
<in Put id= "Txtloginid" type= "text" style= width:190px; "value=" "/>
</td>
</tr>
<tr>
<td style= "width:200px" class= "left" >
Login Password:
</td>
<td style= "width:200p X "class=" left >
<input id= "TXTLOGINPW type=" password "style=" width:190px; "value=" "/>
</td>
</tr>
<tr>
<td style= "width:200px" class= "center" >
<input id= "Btnsignin" va Lue= "Sign in" class= "button" readonly/>
</td>
<td style= "width:200px" class= "center" >
& Lt;input id= "Btnsignup" value= "Sign Up" class= "button" readonly/>
</td>
</tr>
</table >
jquery References and logon events
Code
Copy Code code as follows:
<script src= "Js/jquery-1.4.2.min.js" type= "Text/javascript" ></script>
<script type= "Text/javascript" language= "JavaScript" >
$ (document). Ready (function ()
{
$ (' #btnSignin '). Click
(Function ()
{
$.ajax
(
{
Type: "POST",
ContentType: "Application/json",
url:serviceurl+ "/userlogin",
Data: "{userloginid: '" +$ (' #txtLoginID '). Val () + "', USERLOGINPW: '" +$ (' #txtLoginPW '). Val () + "'}",
DataType: ' JSON ',
Success:function (Result)
{
var user = eval (RESULT.D);
Location.href = "Welcome.aspx?userid=" +user. Userid
},
Error:function (result, status)
{
if (Status = = ' Timeout ')
{
Alert ("The request timed out, please resubmit");
}
Else
{
if (Result.responsetext!= "")
{
Eval ("exception =" +result.responsetext);
Alert (Exception. message);
}
}
}
}
);
}
);
});
$ (document). Ready (function ()
{
$ (' #btnSignup '). Click
(Function ()
{
Location.href = "signup/signup.aspx";
})
});
</script>
Serviceurl similar: var serviceurl = "Http://localhost:1742/SoldierServices.asmx";
WebService Code:
Code
Copy Code code as follows:
<summary>
Summary description for Soldierservices
</summary>
[WebService (Namespace = "http://tempuri.org/")]
[WebServiceBinding (ConformsTo = wsiprofiles.basicprofile1_1)]
[ToolboxItem (False)]
To allow this Web Service to is called from script, using ASP.net AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class SoldierServices:System.Web.Services.WebService
{
[WebMethod]
Public User userlogin (string Userloginid, String userloginpw)
{
loginbusiness lb = new loginbusiness ();
return lb. Userlogin (Userloginid, USERLOGINPW);
}
[WebMethod]
Public User GetUserInfo (string UserID)
{
loginbusiness lb = new loginbusiness ();
return lb. GetUserInfo (UserID);
}
}
Note: [System.Web.Script.Services.ScriptService] is annotated by default, to remove the annotation