function openD(id, last) {
currentId = id;
lastMessage = last;
nameInterlocutor = $("#n" + id).html();
photoInterlocutor = $("#av" + id).attr("src");
$.post("/openD", {id: id}, dialog);
timer = setInterval(function() {
if(!bysy) {
getMessage();
}
}, 3000);
}
function getMessage() {
$.post("/getMessage", {userId: currentId, messageId: lastMessage}, displayMessage);
}
function displayMessage(data) {
bysy = true;
var a = JSON.parse(data);
if(data.length > 0) {
var chat = $("#chat");
$.each(a, function() {
alert(this.text);
$("#chat").append('<div class="message me">' +
'<img src="' + photoInterlocutor + '" />' +
'<div><p><strong>' + nameInterlocutor + ' : </strong>' + this.text + '<br/>' + messageDate.toLocaleDateString("ru", {
hour : "numeric",
minute : "numeric"
}) + '</p></div>' +
'</div>');
lastMessage = this.id;
});
};
bysy = false;
}
Сообщение он получает, alert выполняет (вставил для отладки), но вот новые сообщения на страницу не выводит
$("#chat").append(/* что-то страшное */)
на вашем месте я бы не стал писать такие страсти прямо в функции append, если строки получаются такими сложными, то стоит задуматься о шаблонизаторе.