[英]Javascript Ajax: never ending loading spinner
我不了解行為。 在Firefox 54.0中,我實現了一個非常簡單的Javascript以進行Ajax請求。
Firefox運行良好,但不會停止在選項卡中顯示轉輪。 這似乎不是一個真正的問題,但是我總是被問到為什么。 有人知道原因嗎? Chrome不會顯示該問題,只有Firefox不會。
問候
<!doctype html>
<html>
<head>
<title>Ajax</title>
<meta charset="utf-8">
<script type="text/javascript"> var meinRequest = new XMLHttpRequest();
meinRequest.open ( 'GET', 'daten.txt', true );
meinRequest.onreadystatechange = function(){
if ( meinRequest.readyState == 4 && meinRequest.status == 200 ){
document.write ( meinRequest.responseText );
} else if ( meinRequest.readyState == 4 ){
console.log ( 'Fehler ' + meinRequest.status );
}
}
meinRequest.send();
</script>
</head>
<body>
</body>
</html>
好吧,我自己找到了答案:
document.write()迫使Firefox期望更多。 我簡單地用
document.body.innerHTML += ( meinRequest.responseText );
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.