Page Refresh Timed Event


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Page Refresh Timed Event

Hybrid View

  1. #1
    sanders Guest

    Page Refresh Timed Event


    Hi all,

    I'm working with an E-business app that uses servlets. I need a JavaScript
    for a piece of functionality. I am checking a database to see if there is
    a new record. What I need is for it to keep checkig every X seconds (X to
    be feed to the JavaScript) once the time is reached it needs to call my check
    method. Any ideas would be great.

    Thanks!!!

  2. #2
    Shayne Guest

    Re: Page Refresh Timed Event


    The Javascript function setTimeout is what you are looking for.
    Let's say that your check function is called check(), and you want to run
    this function every three seconds, the appropriate code would be:

    while(true)
    {
    setTimeout("check()",3000);
    }

    This will call check() approx. every 3000 milliseconds (3 seconds).


    If check() requires arguments, the code looks like this:

    while(true)
    {
    setTimeout("check()",3000,arg1,arg2,etc);
    }

    Good luck. Make sure you break out of the while loop when you find the record
    you are looking for.

    "sanders" <cartier_eric@hotmail.com> wrote:
    >
    >Hi all,
    >
    >I'm working with an E-business app that uses servlets. I need a JavaScript
    >for a piece of functionality. I am checking a database to see if there

    is
    >a new record. What I need is for it to keep checkig every X seconds (X

    to
    >be feed to the JavaScript) once the time is reached it needs to call my

    check
    >method. Any ideas would be great.
    >
    >Thanks!!!



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center