【发布时间】:2012-04-27 14:05:20
【问题描述】:
我有以下调用 http 处理程序的脚本。它调用 http 处理程序,在 fiddler 中,我可以看到正确返回的 JSON,但是这个脚本总是以错误块结尾。如何确定问题所在?
<script type="text/javascript">
function GetConfig() {
$.getJSON("http://localhost:27249/Handlers/GetServiceMenuConfiguration.ashx", function(d) {
alert("success");
}).success(function(d) {
alert("success");
}).error(function(d) {
alert("error");
}).complete(function(d) {
alert("complete");
});
}
</script>
【问题讨论】:
-
您能提供回邮给我们吗?并且回发是有效的 JSON 吗?回帖等的标题会很好。
-
使用 JSONLint 并检查返回的 JSON 格式是否正确
-
您的错误处理程序获取三个参数,其中两个对于找出错误是有用的。它们显示了什么?
-
@T.J.Crowder 我看不到有用的信息,我应该看什么 arg?
-
@MrShoubs:错误函数获取the documentation 中描述的三个参数:
jqXHR, textStatus, errorThrown。第一个只是 jQuery XHR 对象。第二个和第三个通常提供更多信息。
标签: javascript jquery json getjson