Is it possible to ask through javascript if there is anything new in a list ul
- li
?
I'm working with a refresh of serInterval
, but it's not very dynamic, why? When the box receives a new message the Scroll Height
does not descend automatically ..
InthisexampleIjustreceivedanewmessage(Red)wherethescrollis,BluenewspaceinScrollHeight
.Thelistul
-li
receives,butstayswhereitwaslasttime.
So,isthereanywayIcansignalthatIgotsomenewli
(message)fortheuser?
Eachli
thatseparatesthemessagesisnamedwithaclasslikethis:
<liclass="colorBox_<?php print $id_m; ?>">...</li>
// $id_m é o id da mensagem na tabela mysql
CODE setInterval:
var loop = setInterval;
function setLoop(de, para, nome) {
var url_ss = $("#url_b").val();
var url_s = $("#url_s").val();
clearInterval(loop);
loop = setInterval(function() {
$.ajax({
type: "POST",
url: url_ss+"/956309372.php",
data: 'de='+de+'¶='+para+'&url_s='+url_s,
cache: false,
success: function(html) {
$("#mensChat div._5chat").html(html);
}
});
}, 1000);
}
CODE calling setInterval:
function openWidChat(de,para,nome) {
var url_s = $("#url_s").val();
$.ajax({
url: url_s +"/chat/chat.php",
data:'de='+de+'¶='+para+'&url_s='+url_s,
type: "POST",
cache: false,
success : function(html){
$("#mensChat div#chat_"+para).html(html);
$("._5chat").scrollTop($("._5chat")[0].scrollHeight);
});
setLoop(de, para, nome);
}
Thank you in advance. ;)