The below code is printing certain values from every row in a CSV that i’m pulling from the server. As you can see in the processLoop function, I am trying to have it delay 3 seconds before displaying the next bit of data. The loop should go on forever. Displaying the contents every 3 seconds.
What it is doing is just quickly displaying everything and the last line in the CSV is what is always showing. If i place an alert before the document.GetElementById line, it will alert me and show the all the data after every alert. So it is looping.. just want it to stop and wait 3 seconds before showing the next bit of data. Please help.
I posted this in JavaScript forum, thinking its not related to jQuery.. but was redirected here. so sorry for double post.
[CODE]<!DOCTYPE html>
<html>
<head>
<meta charset=”utf-8″/>
<title>scratch test</title>
<script src=jquery-1.8.2.js></script>
<script src=jquery.csv.js></script>
<script type=”text/javascript”>
var csvData;
$(document).ready(function() {
csvData = $.ajax({
type: “GET”,
url: “http://localhost/test.csv”,
dataType: “text”,
success: function (result) {
csvResult = result;
processCsvData(csvResult);
}
});
});
function processCsvData(csvResult) {
var data = $.csv.toArrays(csvResult);
for(var row in data) {
for(var item in data[row]) {
processLoop(data);
}
}
}
function processLoop(data) {
setInterval(function(){
var lR;
for (lR = 0; lR < data.length; lR++){
document.getElementById(“test1”).innerHTML = data[lR][0];
document.getElementById(“test2”).innerHTML = data[lR][2];
document.getElementById(“test3”).innerHTML = data[lR][4];
document.getElementById(“test4”).innerHTML = data[lR][5];
}
},3000);
}
</script>
</head>
<body><center>
<p id=test1></p>
<p id=test2></p>
<p id=test3></p>
<p id=test4></p>
</center>
</body>
</html>