I'm trying to get a span to refresh with a php function which queries the database for spaces. However, I can't figure out how to keep it refreshing the actual database content dynamically (preferably via a timer). Here's what I have so far
<script type="text/javascript">
window.onload = startInterval;
function startInterval()
{
setInterval("startTime();",1000);
}
function startTime()
{
document.getElementById('spaces').innerHTML = <?php echo get_spaces($id)?>;
}
</script>
json_spaces.php) and just query it via AJAX every so often.<?php echo get_spaces($id)?>will execute server side and echo a static value. The JavaScript is then compiled client side with that static value so it won't change on subsequent executions (in JavaScript).