1
Hello.
I have a jsp being a chat (due to a restriction, I am using Struts 1). In this JSP, I have the following div
:
<div class="conteudo" id="conteudo" name="conteudo">
.
I need to, return an automatic response (can be anything) from the server whenever the user sends something to the chat page, which I am not able to do. However, I have the script to display user messages on the screen, and it works. The Script is the following:
<script src="inc/jquery.js"></script>
<script>
$(document).ready(function(){
$("#enviar").click(function(){
var mensagem = $("#texto").val();
mensagem = mensagem.replace(/\r?\n/g, '<br />');
var cliente = "Cliente "+":";
var hora = (new Date).getHours();
var min = (new Date).getMinutes();
if(min <10)
min = "0"+min;
var sec = (new Date).getSeconds();
if(sec <10)
sec = "0"+sec;
var horario = hora+":"+min+":"+sec;
$("#conteudo").append($("<div[...]{AQUI SE INSERE A MENSAGEM, E ELA FUNCIONA.}[...]</div>"));
});
});
</script>
There’s nothing I can do to give a kind of append
also?
Remembering that I need any message to be inserted into the chat after someone has typed something.