Hi folks
As you will probably work out, I am only just starting with javascript. (PHP I’m use to).
I’m trying to get the following bit of code to work. Basically, I want to display a page of retrieved data for a period of time then display the next group. As there are only 5 groups, I want it reset back to group 1 after it gets to 5.
Any help would be appreciated.
<html>
<head>
<script type="text/javascript" src="js/jquery.js"></script>
<script>
$(document).ready(function(){
var group = 1;
var callAjax = function(){
$.ajax({
method: 'get',
url: 'get_results.php?gp=' + group,
success: function(data){
$("#latestresults").html(data);
}
if (group == 5) {
group = 1;
} else {
group += 1;
};
});
}
setInterval(callAjax,3000);
});
</script>
<meta equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<?php echo "<div id='latestresults'>Loading Results....</div>"; ?>
</body>
</html>
Thanks in advance.