Hi eveyone,
I'm trying to use ajax to pull records from a database and display them one at a time with a 10 second pause between each record. The following function pulls all of them and displays them at once every 10 seconds.
I'm thinking I need to pull the use PHP to pull the results from the database and store them in an array. Then use JS to iterate through the array. If so, I'm not sure how to do that. Each record has 15 fields. If I'm on the wrong track please let me know what track i should be on. I appreciate any help.Code:function getCat(str) { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("details").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","changeCat.php?x="+str,true); xmlhttp.send(); setTimeout("getCat('yes')",10000); }
Thanks,
Tim


Reply With Quote
Bookmarks