jquery和C#web服务的问题

jquery和C#web服务的问题,c#,javascript,jquery,web-services,C#,Javascript,Jquery,Web Services,来自web服务的输出,”http://localhost:6833/Service1.asmx/HelloWorld“: [{“姓名”:“皮尼”,“年龄”:“30”,“身份证”:“111”},{“姓名”:“亚尼夫”,“年龄”:“31”,“身份证”:“科恩”},{“姓名”:“尤尼”,“年龄”:“20”,“身份证”:“比顿”}] HTML代码: <html> <head> <script type="text/javascript" src="jquery-1.7.

来自web服务的输出,”http://localhost:6833/Service1.asmx/HelloWorld“:


[{“姓名”:“皮尼”,“年龄”:“30”,“身份证”:“111”},{“姓名”:“亚尼夫”,“年龄”:“31”,“身份证”:“科恩”},{“姓名”:“尤尼”,“年龄”:“20”,“身份证”:“比顿”}]
HTML代码:

<html>
<head>
<script type="text/javascript" src="jquery-1.7.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
        type: "POST", 
        url: "Service1.asmx/HelloWorld", 
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {
            alert("Result: " + msg);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert("Error: " + textStatus);
    }
});
});
</script>
</head>
<body>
</body>
</html>

$(文档).ready(函数(){
$.ajax({
类型:“POST”,
url:“Service1.asmx/HelloWorld”,
数据:“{}”,
contentType:“应用程序/json;字符集=utf-8”,
数据类型:“json”,
成功:功能(msg){
警报(“结果:+msg”);
},
错误:函数(XMLHttpRequest、textStatus、errorshown){
警报(“错误:+textStatus”);
}
});
});

在浏览器中运行index.html时,会收到错误警报。。尝试了很多东西,但找不到缺少的东西。

您的json封装在xml字符串中,我想这是您的问题

编辑:


查看post以了解更多信息。

尝试在方法之前添加此项

 [ScriptMethod(ResponseFormat = ResponseFormat.Json)] 
下面


唯一的错误:错误。但不确定该函数是如何工作的,这是全新的尝试此警报(“错误:“+ErrorSprown”);告诉我你得到了什么。想一想,是的,试过了:“,只是”Service1.asmx/HelloWorld“。第一个在我的浏览器中可以正常工作。请尝试“~/Service1.asmx/HelloWorld”,因为路径有问题,请尝试“../../Service1.asmx/HelloWorld”或“/Service1.asmx/HelloWorld”或使用完整路径,您可以将其更改为您的域名。
 [ScriptMethod(ResponseFormat = ResponseFormat.Json)] 
 [WebMethod]