I have a webservice getupdate.php with the following code:
<?php
$aReturn['status'] = "This is the last update";
$aReturn['lastupdate'] = "2 minutes ago";
echo json_encode($aReturn);
?>
It produces the expected output: {"status":"This is the last update","lastupdate":"2 minutes ago"}
I'm trying to update to div's every 5 sec with this:
<script src='http://code.jquery.com/jquery-latest.js'></script>
<script type="text/javascript">
$.ajaxSetup ({
cache: false
});
setInterval(function(){
$.getJSON('getstatus.php', function(data) {
$('div#status').html(data.status);
$('div#lastupdate').html(data.lastupdate);
}
});
}, 5000);
</script>
<div id="status">status</div>
<div id="lastupdate">lastupdate</div>
But for some - most likely very simple reason - my two div's are not updated. Can anyone tell my what I'm doing wrong here?