Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 10th, 2004, 01:19 AM
Authorized User
 
Join Date: Apr 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to pigtail Send a message via Yahoo to pigtail
Default 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);">



 
Old April 10th, 2004, 08:12 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Cross post: http://p2p.wrox.com/topic.asp?TOPIC_ID=12182

pigtail: Please do not cross post (post the same question more than once) on P2P, your question will be read however many times you post it.

Thank you.

Snib

P2P Member
<><





Similar Threads
Thread Thread Starter Forum Replies Last Post
Refresh GridView Using Refresh Button msbsam ASP.NET 2.0 Professional 0 December 6th, 2006 05:57 AM
Does SetInterval spawn many threads? pigtail Javascript 0 April 10th, 2004 11:39 PM
Can I use SetInterval to refresh recordset? pigtail Javascript 4 April 10th, 2004 11:09 PM
Refresh Recordset dhborchardt Classic ASP Databases 3 June 17th, 2003 12:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.