setInterval(function() { $.get('test.php', function(data) { $('.test').append(data); }); }, 2000);
File test.php:
echo time();
In <div class="test"></div>
can get from 2 to 4 identical values. What could be the problem?
setInterval(function() { $.get('test.php', function(data) { $('.test').append(data); }); }, 2000);
File test.php:
echo time();
In <div class="test"></div>
can get from 2 to 4 identical values. What could be the problem?
@ROOT , why complicate things like that, there is a proven solution:
setTimeout(function loop() { $.get('test.php', function(data) { $('.test').append(data); // условие опционально setTimeout(loop, 2000); }); }, 2000);
1) add clearInterval so that they do not accumulate (inside)
2) issue the get package to an additional function and, using an additional blocking variable, prohibit calling this function until you receive a successful response from test.php
Source: https://ru.stackoverflow.com/questions/169778/
All Articles