下面小编就为大家带来一篇js跨域调用webservice的简单实例。小编觉得挺不错的,现在就分享js源码给大家,也给大家做个参考。对js感兴趣的一起跟随小编过来看看吧
步骤1. 在web.config中的system.web节点里加入
步骤2. webservice代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Mvc;
namespace WebService
{
///
/// WebService1 的摘要说明
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
[System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
[ValidateInput(false)]
[WebMethod(Description = "测试")]
public void getDBTableInfos(string EnterpriseCode)
{
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\": \"" + EnterpriseCode + "\" })");
}
}
}步骤3. html页面部分
Index
以上就是小编为大家带来的js跨域调用WebService的简单实例的全部内容了,希望对大家有所帮助,多多支持PHP中文网~
相关推荐:
超级适合代理建设企业站点的企业源码,超方面实用!程序说明: 1.特色:简繁中文切换、产品展示系统、新闻发布系统、会员管理系统、留言本计数器、网站信息统计、强大后台操作 功能等; 2.页面包括:首页、企业介绍、滚动公告通知发布系统、企业新闻系统、产品展示系统、企业案例发布展示系 统、企业招聘信息发布系统、信息资源下载系统、在线定单系统、在线客服系统、在线留言本系统、网站调查投票系统、友情连接系统、会









