I'm building a mini forum, and in it, users can do posts and reply to them.
For the page not to get too long, I put a div
with a fixed height and width, and, if the text goes beyond this value, it will add a scrollbar,
The problem is:
I use AJAX to update the answers from time to time, and whenever I update, and it returns the scroll bar to the starting position, I wanted to know if you have how to get the current scrollbar position within div
, and when you update with ajax , it will return the bar in that position.
This is the code for AJAX
:
<script type="text/javascript">
$(document).ready(function(){
comeca();
})
var timerR = false;
var timerI = null;
function para(){
if(timerR)
clearTimeout(timerI)
timerR = false;
}
function comeca(){
para();
lista();
}
function lista(){
$.ajax({
url:"qrTopico.php",
type: "GET",
dataType: 'html',
data: {topico : "<?php echo $topicoGet; ?>"},
success: function (textStatus){
$('#respostas').html(textStatus); //mostrando resultado
}
})
timerI = setTimeout("lista()", 10000);//tempo de espera
timerR = true;
}
</script>