Here I found an example of the loop(recursive function) delay and used for its own purposes. The problem is that with the successful addition of div I need to stop the cycle, but here is recursive function and so break throws an error.
I tried something like this:
(function myLoop(i){
console.log($("input[name='show']").is(':visible'));
if($("input[name='show']").is(':visible'))
return false;
setTimeout(function(){
$.getScript('index.php?ping=true', function(data){
if(ping){
$('#input').append('<input width="320" type="image" height="240" border="0" src="http://'+url+':'+port+'/?up" name="show">');
}
});
if (--i) myLoop(i);
}, 7000)
})(10);
But it stops only after second div is added. as I understand I need to somehow use the callback on if?

UPDATE:
Solved the problem myself, just added if (–i) myLoop(i); to the getscript
You need to store a reference to your
setTimeoutand the useclearTimeout.