setInterval() does not work correctly when AJAX call is made. Here is the code
xhttp.onreadystatechange = function() {
document.getElementsByTagName('body')[0].innerHTML += this.responseText;
clearInterval(downloadTimer);
document.getElementsByTagName('body')[0].style="pointer-events:none;background: linear-gradient(#000000, #4a4949);height: 100%;margin: 0;background-repeat: no-repeat;background-attachment: fixed;";
var sub = setInterval(alert('Hello'),3000);
};
The problem is with var sub, it should show alert box after 3s, but it shows it right after AJAX call. It does not wait even a sec, I tried to put bigger value than 3000, but the result is the same. I've also tried to use setTimeout, but the result is the same. Any help is more than welcome! Kind Regards
P.S. Everything else in this block works just fine.