Since setTimeout crashes in while loops.
I don't know if there is a way to do it but I am trying to make one. This is how it looks so far.
<script>
var send = true;
function sendit()
{
    alert("test");
    return true;
}
while(true)
{
    if(send == true)
    {
        send = false;
        setTimeout(function(){
            if(sendit() == true) {
                send = true;
            }
        }, 5000);
    }
}
</script>
Is it possible this way?
 
     
    