Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从jQuery 1.9.2调用Web服务_C#_Jquery_Asp.net_Asp.net Ajax - Fatal编程技术网

C# 从jQuery 1.9.2调用Web服务

C# 从jQuery 1.9.2调用Web服务,c#,jquery,asp.net,asp.net-ajax,C#,Jquery,Asp.net,Asp.net Ajax,我只是想从jQuery调用webservice。我的密码是 function SearchCandidates() { $("#txtSearchGlobal").autocomplete({ source: function (request, response) { $.ajax({ type: "POST", url: "WebService.asmx/HelloWorld", contentT

我只是想从jQuery调用webservice。我的密码是

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) {

    }
});
}

在这里,我收到一个错误,说“错误:内部服务器错误[对象对象]”,我无法找到确切的错误。我使用了上面提到的相同代码,很多次都没有发现任何问题。我在这里使用jQuery1.9.2,我不认为版本有问题。有人能帮我吗,先谢谢你

从您的代码中删除else-From-success并进行检查,同时将数据类型设置为Jsonp下面的代码可能会对您有所帮助

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