Here, there is such a javascript code:
function updateChat(){ $.ajax({ url : "http://localhost/kiosl/rooms/default/protected/models/chat-server.php", type : "get", data : "last_displayed_chat_id="+$('#last_displayed_chat_id').val(), dataType : "json", success : function(response , status , http){ $.each(response, function(index,item){ document.getElementById("kiosl_chat_box").innerHTML += "<li class='friend'> <div class='friend-msg-wrap'> <img class='user-img img-circle block pull-left' src='../dist/img/user.png' alt='user'/> <div class='msg pull-left'> <p>" + item.user_comment +"</p> <div class='msg-per-detail text-right'> <span class='msg-time txt-grey'>" + item.user_name + "</span> </div> </div> <div class='clearfix'></div> </div> </li>"; }); }, error : function(http, status, error){ alert('Some Error occured : '+error); } }); } updateChat(); setInterval(updateChat, 1000); And that's the problem: every time in kiosl_chat_box for 1 sec. html code is added:
<li> Бла Бла бла </li>
Question: how to make that the repeating code would not be added.
PS My javascript experience is already divided by 0.
updateChat()function every second. - JamesJGoodwin