I need your help. I'm setting up a chat system, and because I'm a hardhead I'm putting everything in my hands so I can learn. The question is as follows, I have an index.php page and a page called chat.php. I would like to know how to create a script so that I can load the contents of the chat.php page inside a DIV in the index.php page and cause the scroll scroll automatically down. I've tried to do it this way:
<script>
var tempo = window.setInterval(carrega, 5000);
function carrega()
{
$('#chat').load("chat.php");
}
</script>
Of course, the scroll bar will go back to the top after the interval set by the setInterval, even if you scroll down manually. How should I proceed so that she is always down?