I am using the following code but I can't seem to get it to work. If anyone could help or point me in the right direction that would be great. What I'm trying to achieve is a facebook style of alert where the alert will appear without refreshing the page. The number of alerts come from the number of rows in the database. Am I doing anything stupid?
jQuery:
<script type="text/javascript">
var alertNumber = <?php echo $display['alertNumber']; ?>;
setTimeout(checkVariableValue, 2000);
function checkVariableValue() {
$.ajax({
url: 'jquery.php?query='.alertNumber,
success: function(newAlert) {
if (newAlert != alertNumber);
alertNumber = newAlert;
document.getElementById("wibble").innerHTML=alertNumber;
}
});
}
</script>