Question

This is the code:

var LOAD = window.setInterval("LOADING()", 50);

function LOADING()   {
  var y = document.getElementById("cse");
  var str = y.innerHTML;
  if (str !== "Loading") {
    setTimeout('INPUTAI()', 100);
    window.clearInterval(LOAD);
    console.log('Google paieška užsikrovė');
  }  
}

Then page loads and then "Loading" dissmises, in my Google Chrome console I see "Google paieška užsikrovė", but it keeps writing to console, and writing... So clearInterval not works.

Problem solved: changed to

var LOAD = window.setInterval(LOADING, 50);

Thanks ;)

Was it helpful?

Solution

setInterval does not need the function's ():

 var LOAD = window.setInterval(LOADING, 50);
  setTimeout(INPUTAI, 100);

Also, as many people ponted out, the problem may be with the #cse element's content not being exactly "Loading".

OTHER TIPS

Try this out?

var LOAD = setInterval(LOADING, 50);

function LOADING()   {
  var y = document.getElementById("cse");
  var str = y.innerHTML;
  if (str !== "Loading") {
    setTimeout(INPUTAI, 100);
    clearInterval(LOAD);
    console.log('Google paieška užsikrove');
  }  
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top