Hello!) If anyone knows, tell me, please ..
There is a database with messages (guestbook) and the main Message
class. On the main page, messages are displayed in descending order of date.
When we add a new message to the database, it is added. A new object of the class Message
(I make a request via an AJAX request, I make a return array with returned fields).
But I don’t know how to update the list of messages without rebooting.
$('form').submit ( function( e ){ e.preventDefault(); $.ajax({ url : 'save1.php', type : 'post', data : $('form').serialize() }).done( function ( data ){ var result = $.parseJSON( data ); $("#block").append( result ); // не работает.. }); });
On the main page, messages are displayed using the Меssage:getList
and each message is formatted with a div of the block
class.
$arMessages = Message::getList(); while ($row = mysql_fetch_array($arMessages)) { ?> <div id="block" class="w"> <p> <strong>Посетитель : </strong><? echo $row['username'] ?></p> <p><strong> Email : </strong> <? echo $row['email'] ?> </p> <p><strong> Дата добавления : </strong><? echo $row['date'] ?> </p> <p><strong> Сообщение : </strong><? echo $row['msg'] ?> </p> <br /> <button class="j-delete" data-id=" <? echo $row['id'] ?>"></button> </div>