setInterval() issue..
Posted: Wed Aug 08, 2012 11:15 pm
I'm using setInterval to read a log that is updated frequently. However, if I want to select the text it displays from the log, when it refreshes it, I cannot select the text because of it refreshing. So my question here would be, how do I make this load ONLY when a new entry is created?
An example:
An example:
Code: Select all
$(function() {
function loadlog() {
var oldscrollheight = $("#log").prop("scrollHeight") - 20;
$.ajax({
url: './assets/log.php',
cache: false,
success: function(data) {
$("#log").html(data);
var newscrollheight = $("#log").prop("scrollHeight") - 20;
if(newscrollheight > oldscrollheight)
$("#log").animate({scrollTop: newscrollheight}, 'slow');
}
});
}
setInterval(loadlog, 100);
});