2
以下代碼調用JSON並顯示結果,但似乎頁面從未完成加載。瀏覽器仍然說連接和查看源碼不會顯示 任何想法?Jquery getJson頁面永不加載
<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>
剛剛看到你的'.error'調用,但它仍然可能是AJAX失敗(或者只是加載有問題的資源)。無論哪種方式,我們都需要更多關於該頁面的信息來得出關於它爲什麼空閒的結論。 –
這是唯一的頁面上的代碼。這是jsonp調用http://php.pressconnects.com/roadcond?callback=? –
請注意,如果它是_that_大交易,但[JSONLint](http://www.jsonlint.com)表示響應格式錯誤。 - 沒關係,因爲我正在免除jsonp回調。 :累: –