I'm writing a chat for my site in ajax and jquery, I created a jquery function that repeats every 3 seconds to retrieve new messages, but if on the same browser I open any other window on my site at the same time as that of my site with the chat I don't get back the data, that is, I don't see the message
$('#div-chat-more').ready(function() {
setInterval(function() {
var listamessg = $(this).attr('data-listamessg');
var urltot = "/cffunctions.cfc?method=SalesMorechat&lstmsg=" + listamessg
$('.div-chat-more').val('');
$.ajax({
type: "GET",
url: urltot,
success: function(data) {
if (data != "") {
/*$('html,body').animate({
scrollTop: $(window).scrollTop() + 100
}, 500);*/
$('.div-chat-more').append($(data));; /*alert("alert2!")*/
$('.scroll-chat').animate({
scrollTop: $('.scroll-chat').scrollTop() + 100
}, 100);
/*$('#btn-chat-more').attr('data-page',counter);*/
/*$('.div-chat-more').hide();*/
}
/*else {alert("alertno!");}*/
},
error: function() {
alert("alert2!");
/*$('#msg-sales-more').show();*/
$('.div-chat-more').hide();
}
});
return false;
}, 3000);
});