I am creating a basic forum where each post contains the name of the author, the text and the date it was created. I would like the forum to be constantly updated via AJAX and show new posts that were created on the fly. Currently, I have a PHP file getlatest.php?lastid=...that retrieves all messages from the identifier specified for the most recent one. It returns data in HTML, for example (I changed it so that you can see divs, stackoverflow throws it away):
foreach ($print as $value)
{
$readyText .= div id = $value->post_id;
$readyText .= $value->first_name.' '.$value->last_name.' posted the following:'.
$value->post_text.' The post was made about '.$time.' ago.
$readyText .= '/div>';
}
I have some AJAX code in jquery that retrieves every few moments
setInterval("update()", 3000);
function update()
{
$.get("getlatest.php",
{
id: latestmessage
},
function(response){
$("#forum_entries").prepend(response);
latestmessage = $.cookie('last_post_id');
}, "html");
I wanted to highlight all the new messages that were sent using the (now very popular) yellow wilting technology, for example
$ ("# somediv"). effect ("highlight", {}, 1500);
- div ?
PHP, div, PK .
rashcroft