【问题标题】:Calling Web Service from jQuery 1.9.2从 jQuery 1.9.2 调用 Web 服务
【发布时间】:2013-07-25 05:36:46
【问题描述】:

我只是想从 jQuery 调用 web 服务。我的代码是,

function SearchCandidates() {
$("#txtSearchGlobal").autocomplete({
    source: function (request, response) {
        $.ajax({
            type: "POST",
            url: "WebService.asmx/HelloWorld",
            contentType: "application/json; charset=utf-8",
            data: "{}",
            dataType: "json",
            success: function (data) {                    

            },
            error: function (req, status, error) {
                alert("ERROR:" + error.toString() + " " + status + " " + req);
            }
        });
    },
    minLength: 2,
    select: function (event, ui) {

    }
});

}

在这里,我收到一条错误消息 "ERROR : Internal Server Error error [object object]",我无法找到确切的错误。我已经多次使用上述相同的代码,但我没有发现任何问题。我在这里使用 jQuery 1.9.2,我认为版本不是问题。任何人都可以在这里帮助我,在此先感谢。

【问题讨论】:

    标签: c# jquery asp.net asp.net-ajax


    【解决方案1】:

    从您的代码中删除 else 成功并检查并将数据类型设置为 Jsonp 下面的代码可能会帮助您

    $.ajax({
     type: "POST",
    url: url,
    data: data,
     dataType: 'jsonp'
    success: function(data){
     alert(data)
    },
    error:function(req, status, error){
     alert(JSON.stringify(error))
    }   
    });
    

    【讨论】:

      猜你喜欢
      • 2012-06-18
      • 2011-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-31
      • 2013-04-08
      • 1970-01-01
      相关资源
      最近更新 更多