相关疑难解决方法(0)

jQuery调用WebService返回"No Transport"错误

我有以下网络服务;

    [WebMethod]
    public string HelloWorld()
    {
        return "Hello World";
    }
Run Code Online (Sandbox Code Playgroud)

它是库存标准,没有对类装饰器进行任何改动.

我有这个jQuery方法;

var webMethod = "http://localhost:54473/Service1.asmx/HelloWorld"; 

$.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    data: "{}",  
    dataType: "json",
    url: webMethod,
    success: function(msg){ alert(msg.d); },
    error: function (XMLHttpRequest, textStatus, errorThrown) {
        alert(errorThrown);
          }
});
Run Code Online (Sandbox Code Playgroud)

这是一个后期操作,因为稍后我需要将数据发布到它.

当我执行jQuery时,我得到一个"无传输"错误.

我还应该提到的一点是,jQuery存储在我的机器上的一个简单的HTML文件中,而WebService也在我的机器上运行.

HTML页面上没有代码,它只是一个网页,而不是ac #project或任何东西.

任何人都可以指出我在正确的方向吗?

ajax jquery web-services

163
推荐指数
5
解决办法
17万
查看次数

标签 统计

ajax ×1

jquery ×1

web-services ×1