[英]Jquery getJson page never finishes loading
The following code calls the JSON and displays the results but then it seems like the page never completes loading. 以下代码调用JSON并显示结果,但是页面似乎从未完成加载。 The browser still says connecting and view source never displays Any ideas?
浏览器仍然说连接并且查看源代码从不显示任何想法?
<script>
function getroadcondFiles () {
jQuery.support.cors = true
// electdiv=electdiv+"</center><br>";
$.getJSON('http://example.com?callback=?',function(dataa){
// console.log("before each");
//console.log(dataa.result.totalCount);
$.each(dataa.roadid, function(i,item){
document.write(item.desc+"<br>");
document.write(item.overstat[0]+"<br>");
document.write(item.weatherstat[0]+"<br>");
document.write(item.pavementstat[0]+"<br>");
});
;}).error(function(jqXHR, textStatus, errorThrown) { alert(errorThrown); });
;}
</script>
</head>
<body>
<script>
$=jQuery;
getroadcondFiles();
</script>
Check for an $.ajaxError
or use your browser's debugger to get more insight in to the failure. 检查
$.ajaxError
或使用浏览器的调试器以更深入地了解故障。 Without knowing if the json call is failing (and no error besides "this doesn't work") there's no way to tell what's failing. 不知道json调用是否失败(除了“这不起作用”以外没有错误),无法判断失败的原因。
I recommend using $.ajax
and the error
property to determine if there is a problem occurring with the query. 我建议使用
$.ajax
和error
属性来确定查询是否发生问题。 one you find out if it's the query or the script you'll be better informed on how to correct the issue. 您会发现它是查询还是脚本,您将可以更好地了解如何更正此问题。
it may not even be ajax failing though, it could be another script still processing. 它甚至可能不是ajax失败的,它可能是另一个仍在处理的脚本。 Once again, use your browser's debugging tools to get more insight in to what's actually the original problem.
再一次,使用浏览器的调试工具来更深入地了解真正的原始问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.