473,323 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

How to implement a timer with ajax. A real-time solution??

348 100+
Hi everyone, I usually hang out on the php side because its what I know, but I am faced with a problem that I honestly have no idea how to solve and figured I would try my luck over here. I am hoping that a few of you AJAX gurus can point me in the direction I need to go. Any help or comments would be appriciated.

I have an application written in php and I need to use some kind of control that will keep a timer going. This is a dispatching type of program that uses a database. When the user enters data into the db, this "timer" should start counting and when it reaches a time specified by the system administrator, the app should play a sound byte and flash that particular row of data indicating to the user that this time limit is up.

Could someone please help me with a solution? I was told that AJAX could do this. If not, would anyone know what method may work for this problem?

Thanks,

Frank
Jun 16 '08 #1
5 1877
acoder
16,027 Expert Mod 8TB
When you say the user "enters data into the db", do you mean via a PHP script? You may not need Ajax at all, though you would need JavaScript. What you need to use is setTimeout. You could make a request using Ajax. When the request is complete, start the timer which calls a function on completion. This function would play the sound file and flash the row or whatever.
Jun 16 '08 #2
fjm
348 100+
Thanks for the response acoder. Yes, the user will enter data into the database via a php script. The timout should be row specific. In other words, if there are 100 rows of data (Very very unlikley) each row will have a different timout.

Looking at the DOM code:

Expand|Select|Wrap|Line Numbers
  1. timeoutID = window.setTimeout(funcdelay, [param1param2, ...]);
Wouldn't I need something to tell setTimout when the row was created or modified? Also, I don't know anything about js, so forgive me if I sound square but isn't window.setTimout for the window? I would need this function for rows within the window. :) Again, please forgive my nubish glow.
Jun 16 '08 #3
acoder
16,027 Expert Mod 8TB
You mentioned in the first post that the timer would start when the user has entered data into the database. If you're using Ajax, you can start the timer when the request is complete, or if you want, when you start the request (though that may be unreliable). setTimeout can call a function which can deal with the required functionality for each row.

In case you need something to get you started with Ajax, here's a quick howto. If you need help implementing the Ajax code, let me know.
Jun 16 '08 #4
fjm
348 100+
Hey acoder. Thanks for the link. Unless I am missing something, (and I probably am) the example ajax in the link you gave does nothing more than populate a dropdown box from a db. I can do that with straight php.

What am I missing :)

Frank
Jun 17 '08 #5
acoder
16,027 Expert Mod 8TB
Yes, that's correct. It was, after all, only an example. The difference would be that it would populate the drop down without leaving the page which PHP alone couldn't do. Alternatively, you could use a framework/library to do it for you. Many have animation effects too.
Jun 17 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: wukexin | last post by:
I write my own class Cfile, I want to know what about implement ctime().Who help me? My use function ctime, I sign it with $$$. my class Cfile: #------------------------ file.h...
1
by: Ismail | last post by:
Hello, I have webform and usercotnrol with asp:Timer on it. I am in tick event doing count down of timer. What i want to do is when the countdown is complete stop the timer. I tried...
0
by: hzq3554055 | last post by:
i am novice,guess the following code can work combineing with server- side code ,but chaos ï¼›somewhere to me is great<script> var relationObject = {timer: null, key: ""}; function...
10
by: =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?= | last post by:
controlsPlease could some of you here post some of your live examples of AJAX (esp drag panels, collapsable panels, and popup menu.) (It's one thing to talk about how great something is, but it's...
0
by: datla20s | last post by:
Luckly, I found an example to show what exacty I am looking for: Go to the following yahoo link: http://travel.yahoo.com/;_ylc=X3oDMTE5MGRqZDdoBF9TAzI3MTYxNDkEc2VjA2ZwLXRy...
6
by: Nico VanHaaster | last post by:
Ok, I am really frustraited. I just started looking into the Ajax ASP.net. And have some real big issues. And its only with Visual Studio. I have installed the AJAX 2.0 off of www.asp.net/ajax...
0
by: news.rz.uni-karlsruhe.de | last post by:
I want to deactivate the Ajax timer from clientside with javascript - that is, it should not raise any postbacks any more. Which method/propertie is there I can use to chieve this and most...
29
by: canabatz | last post by:
Hello , i got this code that works great , now i want to have it refresh every 4 seconds , where can i put the timer to do that? i realy need help!! thanx!! <script type="text/javascript">...
22
by: canabatz | last post by:
Hi all! i got a countdown timer for auctions that runing. i got a DIV that refreshs every 4 seconds that DIV is refreshed by ajax ,the file that is refreshed is timer.php for example!! my...
1
by: nehalsmistry | last post by:
Hello.. I am using visual studio 2005. So there is framework 2.0 Now I m using ajax toolkit for 2.0 and installed it. But there is no option like Asp.net ajax enable website. But there is 1...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.