Forum Moderators: open
I have ajax code which retrieves a text string from the server in the following format:
row1,100
row2,150
row3,80
.
.
rowX,nnn
The html page has a simple table:
Widget Type Price
-----------------
Green Widgets 100
Blue Widgets 150
Red Widgets 80
.
.
X Widgets nnn
The widgets text is static but I need to update just the Price column.
I guess I just need many divs in there with ids from 1 to x?
Second question: How do I get the page to retrieve prices every 60 seconds?
I'll leave out the meat of the ajax stuff. Below is the process response routine which builds the data for displaying.
Assume the server php file returns a text string of
110¦85¦203
function processResponse() {
if(http.readyState == 4){
var response = http.responseText;
if(response.indexOf('¦'!= -1)) {
var update = response.split('¦');
for (var i = 0; i < update.length; i++)
document.getElementById('widgets'+i).innerHTML = update[i]; }
}
}
.
.
.
<p><a href="javascript:makeGetRequest(1)">Update Prices</a></p>
Green Widgets <div id='widgets0'></div>
Blue Widgets <div id='widgets1'></div>
Red Widgets <div id='widgets2'></div>