if ($numOfMessages <> 0)
{
echo "<span class='headings_sub' id='msgcntDiv'>You have " .$numOfMessages . "</span>";
echo "<a class='red_link' href='".ADDRESS."messages.php'> unopened Messages</a>";
}
的Jquery:
<script>
$(document).ready(function() {
refresh();
});
function refresh()
{
$.get('newMessageCnt.php', function (cnt) {
$("#msgcntDiv").data('cnt', cnt);
window.setTimeout(refresh,30000);
});
}
</script>
newMessageCnt.php:
<?php
include('header_application.php');
$obj_clean->check_user(); //$obj_clean defined/initialized in header_application
echo $obj_clean->getUnopenedMessagesCount($_SESSION['user_id']);
?>
任何意見嗎? 謝謝