欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

jQuery AJAX 调用 WebService 的实例

程序员文章站 2022-05-15 14:02:27
...
用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]默认是注释的,要把注释去掉