作者:何炘柱_549 | 来源:互联网 | 2018-06-15 19:39
用jQuery调用其他项目的WebService
实现登录验证功能
html输入用户名密码:
代码
代码如下:
Jquery引用和登录事件
代码
代码如下:
serviceURL类似:var serviceURL = "http://localhost:1742/SoldierServices.asmx";
WebService代码:
代码
代码如下:
///
/// Summary description for SoldierServices
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(COnformsTo= WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// To allow this Web Service to be 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);
}
}
注意:[System.Web.Script.Services.ScriptService]默认是注释的,要把注释去掉