Home >Backend Development >PHP Tutorial >Example of jQuery AJAX calling WebService_PHP tutorial

Example of jQuery AJAX calling WebService_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 14:54:411033browse

用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);
}
}

Note: [System.Web.Script.Services.ScriptService] is commented by default. You need to remove the comments.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/364545.htmlTechArticleUse jQuery to call the WebService of other projects to implement the login verification function html enter the username and password: Code table style=width: 400px tr td style=width: 200px class=left Login ID: /td td s...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn