Note that there are some explanatory texts on larger screens.

plurals
  1. POsetInterval not working properly
    text
    copied!<p>I have been searching all over the internet tonight, saw a lot of "solutions" but not working for me unfortunately. So I will try to get different answer of what I am seeing here on stack and elsewhere and hoping I will find one which will work... </p> <p>My page has the following javascript bit:</p> <pre><code>logbook = setInterval(function () { $.getJSON("php/log.php", function(data) { $.each(data.posts, function(i,data) { $('#logspan').replaceWith(data.logupdate); }); }); }, 5000); </code></pre> <p>When I run the page, it works, but only ONE time and then it stops the interval completely (this is in Chrome and Firefox) and basically gives up.</p> <p>This is weird, because there is yet another script which is running as follows and is doing its job perfectly:</p> <pre><code>var timer; function startCount() { timer = setInterval(count,1000); } function count() { var el = document.getElementById('counter'); var currentNumber = parseFloat(el.innerHTML); el.innerHTML = currentNumber+1; } </code></pre> <p>I already tried to see if the first script works if I turned the second one off, but it is still no go. So, how can I ever make the first (JSON) script work? It is way past my bedtime thanks to this problem and I haven't gotten any step further!! <em>pulls hair</em></p> <p>Any suggestions / hints / tips are appreciated...</p> <p>EDIT: Ok, I found something peculiar, when I replace the "replaceWith" and use "appendTo" it seems to update the #logspan just fine, but obviously I do not want to spam my own webpage. Maybe the problem lies somewhere else?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload