首頁  >  文章  >  web前端  >  jQuery AJAX 调用WebService实现代码_jquery

jQuery AJAX 调用WebService实现代码_jquery

WBOY
WBOY原創
2016-05-16 18:31:23782瀏覽

用jQuery调用其他项目的WebService
实现登录验证功能
html输入用户名密码:
代码

复制代码 代码如下:















Login ID:



Login Password:








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]默认是注释的,要把注释去掉
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn