I have a variable in a span tag:
echo "<span class='headings_sub' id='msgcntDiv'>You have ".$numOfMessages." </span>";
My script:
<script>
$(document).ready(function() {
var reload = function(){
$("msgcntDiv").load("newMessageCnt.php");
}
window.setInterval(function() {
$("#msgcntDiv").load(reload);
}, 10000);
});
</script>
"newMessageCnt.php" has one line:
<?php
include('header_application.php');
$pageValue = "dashboard";
$obj_clean->check_user();
echo $numOfMessages = $obj_clean->getUnopenedMessagesCount($_SESSION['user_id']);
?>