简体   繁体   English

jQuery getJson页面永远不会完成加载

[英]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. 我建议使用$.ajaxerror属性来确定查询是否发生问题。 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.

相关问题 禁用JavaScript时,IE永远不会完成SharePoint页面的加载 - IE Never finishes loading SharePoint page when JavaScript is disabled jQuery $ .post回调触发一个永不结束的函数 - JQuery $.post callback firing a function that never finishes jQuery getJSON永远不会进入其回调函数 - jQuery getJSON never enters its callback function jQuery getJSON回调函数在完成之前不会更新DOM - jQuery getJSON callback function doesn't update the DOM until it finishes Google Analytics(分析)事件跟踪:__utm.gif永远不会完成加载 - Google Analytics Event Tracking: __utm.gif never finishes loading 如何在加载页面之前运行 jQuery 或如何回调“getJson(function(data))”? - How to run jQuery before loading page or how can call back "getJson(function(data))"? 即使我正在使用 $(window).on(&#39;load&#39;, function(),jQuery 也会在页面完成加载之前执行 - jQuery executes before page finishes loading even though I'm using $(window).on('load', function() 当页面完成加载时,我如何使我的模态 jquery 加载 - how do i make my modal jquery load when page finishes loading 另一个完成加载后加载新页面 - Load a new page after another finishes loading 调用函数直到jQuery .post完成加载 - Calling a function until jQuery .post finishes loading
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM