Suppose I have an array which contains 2 itmes. Also I have 2 divs (mydiv1, mydiv2). First div has to be filled by first item of the array and second div has to be filled by the 2nd item of the array at the same time. And this process will repeat after regular intervals. I will keep on populating this array with new items by fetching from database, but that is out of scope of my question right now. How should I do this?
My xyz.php file is
<?php
//echo rand();
$questions=array(
"First Item",
"Second Item"
);
?>
index.php
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var auto_refresh = setInterval(
function ()
{
$('#mydiv1').load('xyz.php').fadeIn("slow");
}, 1000); // refresh every 1000 milliseconds
});
</script>
</head>
<body>
<div id="mydiv1"> </div>
<div id="mydiv2"> </div>
</body>