A simple example of js cross-origin WebService calling. js cross-origin webservice
Step 1.Add the following content to the system. web node in web. config:
<! -- This node allows scripts to call webservice across domains --> <webServices> <protocols> <add name = "HttpPost"/> <add name = "HttpGet"/> </protocols> </webServices> <! -- This node allows scripts to call webservice across domains -->
Step 2.Webservice code
Using System; using System. collections. generic; using System. linq; using System. web; using System. web. services; using System. web. mvc; namespace WebService {// <summary> // abstract description of WebService1 /// </summary> [WebService (Namespace = "http://tempuri.org/")] [WebServiceBinding (ConformsTo = WsiProfiles. basicProfile1_1)] [System. componentModel. toolboxItem (false)] // to allow ASP. net ajax calls this Web service from the script. Please cancel the comments to the downstream . [System. web. script. services. scriptService] public class WebService1: System. web. services. webService {[ValidateInput (false)] [WebMethod (Description = "test")] public void getDBTableInfos (string performanisecode) {HttpContext. current. response. contentType = "application/json; charset = UTF-8"; string jsonCallBackFunName = string. empty; jsonCallBackFunName = HttpContext. current. request. params ["jsoncallback"]. toString (); HttpContext. current. response. write (jsonCallBackFunName + "({\" Result \ ": \" "+ performanisecode + "\"})");}}}
Step 3.Html page
<! DOCTYPE html>
The above is all the simple examples of js cross-origin WebService calling provided by xiaobian. I hope it will be helpful to you and support more customers ~