I have following index.php file:
<html lang="en">
<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 (){
//alert("abc");
$('#mydiv').load('xyz.php').fadeIn("slow");
}, 1000);
});
</script>
</head>
<body>
<div id="mydiv"> </div>
</body>
</html>
In above file, I am trying to call my xyz.php file after 1 seconds. Its working fine. Following is my xyz.php file.
<?php
//echo rand();
$questions=array(
"Array Item 1",
"Array Item 2",
"Array Item 3");
?>
Earlier I was calling rand function, which was generating random number everytime when this file was called after every second. Now I have commented it out. My requirements have been changed. Now I want that when first time this file is called, Array Item 1 is echoed. 2nd time Array Item 2 is echoed. Similar Array Item 3 at third attempt. After this setInterval should not call this php file.
Here I need your help.