There is for example a similar:
count = 3; setInterval(function(){ alert(count); }, 100); Here's how I perform this function exactly three times?
There is for example a similar:
count = 3; setInterval(function(){ alert(count); }, 100); Here's how I perform this function exactly three times?
Each time we decrease the count , if it is zero, then we clear setInterval , using the function clearInterval .
count = 3; var id = setInterval(function() { $.post("/ds.php", { i: count}, function(data) {}); //ваша функция alert(count--); //уменьшаем счетчик if (count <= 0) clearInterval(id); //если равен нуля, очищаем }, 100); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> count , asynchronously, I see no problems doing so. - Mr_Epic let count = 3; function tmp(){ alert(count); if(count > 1){ setTimeout(tmp, 100); // Не используем интервал, ибо равные промежтки получить сложно (см. https://habrahabr.ru/post/138062/) count--; } } tmp(); Source: https://ru.stackoverflow.com/questions/520170/
All Articles