Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Jage, your solution works fine. I do some adaptations in the RetrieveMessages Lets see the code:</p> <pre><code> function RetrieveMessagesSucess(result) { // parsin the json and storing the messages in a array var myMsgs = new Array(); for (var i = 0; i &lt; result.length; i++) { var obj = eval('(' + result[i] + ')'); if (obj != null) myMsgs[i] = obj; } for (var j = 0; j &lt; myMsgs.length; j++) { if (myMsgs.length &gt; 0) { // Verifing if the message already exists var divExiste = document.getElementById(myMsgs[j].cd_chat_message); // If not exists, put the message on the page if (divExiste == null) { // Storing the id of tha last received message. This is useful as a parameter to retrieve messages again IdLastMsg = myMsgs[myMsgs.length - 1].cd_chat_message; // Trick to a zebra style if (par) { var novoconteudo = "&lt;div id='" + myMsgs[j].cd_chat_message + "' style='background-color: #EFEFEF; padding: 10px;'&gt;" par = false; } else { var novoconteudo = "&lt;div id='" + myMsgs[j].cd_chat_message + "' style='padding: 10px;'&gt;" par = true; } // Putting the message on page if (myMsgs[j].origem_mensagem == 1) // Msg enviada pelo cliente novoconteudo = novoconteudo + "&lt;b&gt;" + myMsgs[j].solicitante + ": &lt;/b&gt;" else novoconteudo = novoconteudo + "&lt;b&gt;" + myMsgs[j].tecnico + ": &lt;/b&gt;" var objDate = eval(myMsgs[j].datahora.replace(/\/Date\((\d+)\)\//gi, "new Date($1)")); novoconteudo = novoconteudo + "(" + objDate.format("HH:MM:ss") + ") "; novoconteudo = novoconteudo + myMsgs[j].texto + "&lt;/div&gt;"; divChatHistory.append(novoconteudo); AutoScroll(); if (myMsgs[j].origem_mensagem == 2) // Msg enviada por um tecnico show_popAlert() } } } IsChatInativo(); } </code></pre> <p>Thats it guys.</p> <p>Thanks a lot!</p> <p>excuse my bad English =o)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload