Can I use setInterval to refresh recordset??
I have a JavaScript that uses setInterval to call a function every 5 seconds. This function reads a record from the database, use DOM to replace the data in my table. I added a column that shows a running timer just to make sure that the data was replaced correctly using DOM. After I launched the page, I made an update to the column in the database. The page kept displaying the same value from the first time the page was loaded. The column for the timer continued to change correctly. So, I believe that the recordset returned wasn't refreshed during all subsequent called to this function using the setInterval method. If I refreshed the page, I got the new value from the database. Does anyone has this experience and know how to fix it? See my sample code below:
In the Head section:
var call_work_timerID = 0;
function StartCallWorkTimer()
{
<%
var adoConnection = Server.CreateObject("ADODB.Connection");
adoConnection.Open("DSN=ic613; UID=oadba; PWD=oadba");
var adoRecordset = Server.CreateObject("ADODB.Recordset");
var QStr= "my query string that finds one matching record";
adoRecordset.Open(QStr, adoConnection);
if (adoRecordset.Eof == false && adoRecordset.Bof == false)
{ X= adoRecordset("idleavaildur").Value;
Y= <my current time in milliseconds>;
}
<Use DOM to replace my X and Y fields in my table here>
adoRecordset.Close();
adoRecordset = null;
adoConnection.Close();
adoConnection = null;
}
In the Body:
<input type=button name=btnStop1 value="Start" onclick="javascript:call_work_timerID=setInterval( 'StartCallWorkTimer()',5000);">
<input type=button name=btnStop2 value="Stop" onclick="javascript:clearInterval(call_work_timerI D);">
|