简体   繁体   English

Javascript Ajax:永不停止加载微调器

[英]Javascript Ajax: never ending loading spinner

I am facing a behaviour, I don't understand. 我不了解行为。 In Firefox 54.0 I have implemented a pretty simple Javascript to make an Ajax-request. 在Firefox 54.0中,我实现了一个非常简单的Javascript以进行Ajax请求。

The Firefox works well, but doesn't stop to show the spinning wheel in the tab. Firefox运行良好,但不会停止在选项卡中显示转轮。 This seems to be not a real problem but I always get asked, why. 这似乎不是一个真正的问题,但是我总是被问到为什么。 Does anyone know the reason? 有人知道原因吗? Chrome dosn't show that problem, only Firefox. Chrome不会显示该问题,只有Firefox不会。

Regards 问候

<!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>

Okay, just found the answer myself: 好吧,我自己找到了答案:

The document.write() forces firefox to expect more. document.write()迫使Firefox期望更多。 I simple replaced it with 我简单地用

document.body.innerHTML += ( meinRequest.responseText );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM