HighDots Forums  

javascript timer to cgi

Javascript JavaScript language (comp.lang.javascript)


Discuss javascript timer to cgi in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
jason_box
 
Posts: n/a

Default javascript timer to cgi - 05-04-2006 , 06:09 PM






Hello, I was wondering if there was a way to have a javacript be
activated by an input button that would call to a cgi program and
querey every 10minutes and the cgi would update the page without
additional user interaction. I found some timer stuff in js but it had
to do with delays and not what I was really looking for. Thank you in
advanced.


Reply With Quote
  #2  
Old   
Evertjan.
 
Posts: n/a

Default Re: javascript timer to cgi - 05-04-2006 , 06:19 PM






jason_box wrote on 05 mei 2006 in comp.lang.javascript:

Quote:
Hello, I was wondering if there was a way to have a javacript be
activated by an input button that would call to a cgi program and
querey every 10minutes and the cgi would update the page without
additional user interaction. I found some timer stuff in js but it had
to do with delays and not what I was really looking for.
But ....

CGI works on the server, and updating a page is done by the client.

The CGI programme cannot press a clientside button, so the user has to
presss it every 10 minutes?

Where do you want the javascript to run?

On the client browser, or on the server [under ASP]?

What is the difference between waiting and a delay?

Quote:
Thank you in advanced.
Not that advanced I hope.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)


Reply With Quote
  #3  
Old   
jason_box
 
Posts: n/a

Default Re: javascript timer to cgi - 05-04-2006 , 06:25 PM



Hello, Thank you for your quick response. I should clarify myself if my
question was a little confusion. The cgi script just calls to a local
server to output some data from the server which works. On the html
page I wanted a javascript that would be activiated and call the cgi
program and call to the cgi every 5-10minutes. The cgi will already
outputs the data to the main html page but I would like it to be only
active when a user wants the data. Since I do not want to over request
from the server, the javascript should just call to the cgi every
10minutes until the user press a stop button whcih cuases the
javascript to stop. I think this can be done with on() and off()
functions but I was not sure how to do this yet. The javascript will be
ran through the client side so of course it will require some
interaction. I hope this clears up any confusion. Thank you again.


Evertjan. wrote:
Quote:
jason_box wrote on 05 mei 2006 in comp.lang.javascript:

Hello, I was wondering if there was a way to have a javacript be
activated by an input button that would call to a cgi program and
querey every 10minutes and the cgi would update the page without
additional user interaction. I found some timer stuff in js but it had
to do with delays and not what I was really looking for.

But ....

CGI works on the server, and updating a page is done by the client.

The CGI programme cannot press a clientside button, so the user has to
presss it every 10 minutes?

Where do you want the javascript to run?

On the client browser, or on the server [under ASP]?

What is the difference between waiting and a delay?

Thank you in advanced.

Not that advanced I hope.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)


Reply With Quote
  #4  
Old   
Evertjan.
 
Posts: n/a

Default Re: javascript timer to cgi - 05-04-2006 , 06:35 PM



jason_box wrote on 05 mei 2006 in comp.lang.javascript:

Quote:
Hello, Thank you for your quick response. I should clarify myself if my
question was a little confusion. The cgi script just calls to a local
server to output some data from the server which works. On the html
page I wanted a javascript that would be activiated and call the cgi
program and call to the cgi every 5-10minutes. The cgi will already
outputs the data to the main html page but I would like it to be only
active when a user wants the data. Since I do not want to over request
from the server, the javascript should just call to the cgi every
10minutes until the user press a stop button whcih cuases the
javascript to stop. I think this can be done with on() and off()
functions but I was not sure how to do this yet. The javascript will be
ran through the client side so of course it will require some
interaction. I hope this clears up any confusion. Thank you again.
[please do not toppost on usenet]


<button
onclick='var tmt = setInterval("doCallServer()",10*60*1000)'>
start</button>

<button onclick='clearInterval(tmt)'>
stop</button>


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)


Reply With Quote
  #5  
Old   
jason_box
 
Posts: n/a

Default Re: javascript timer to cgi - 05-04-2006 , 09:04 PM



Quote:
button
onclick='var tmt = setInterval("doCallServer()",10*60*1000)'
start</button

button onclick='clearInterval(tmt)'
stop</button
Which part of the segment of code do I make the call to the cgi
program?
I was thinking of using general input forms and have it submit and post
to cgi, but that would still leave me with the timing issue.

Also on another note, on this line

Quote:
onclick='var tmt = setInterval("doCallServer()",10*60*1000)'
10*60*1000, what units is this in?

Thank you.



Reply With Quote
  #6  
Old   
ASM
 
Posts: n/a

Default Re: javascript timer to cgi - 05-04-2006 , 10:18 PM



jason_box a écrit :
Quote:
button
onclick='var tmt = setInterval("doCallServer()",10*60*1000)'
start</button

button onclick='clearInterval(tmt)'
stop</button


Which part of the segment of code do I make the call to the cgi
program?
you'll need to create your function doCallServer()

i.e : to submit your form nammed 'myForm'

function doCallServer() {
document.forms['myForm'].submit();
}

Quote:
I was thinking of using general input forms and have it submit and post
to cgi, but that would still leave me with the timing issue.
The problem will be : on datas sent back from your cgi
the start button will have to be pushed again.
Perhaps could you send with theses datas some JS script to automatically
re-start the timer

<script type="text/javascript">
var tmt;
onload = function() {
tmt = setInterval("doCallServer()",10*60*1000);
}
</script>

Quote:
onclick='var tmt = setInterval("doCallServer()",10*60*1000)'

10*60*1000, what units is this in?
milliseconds (here : 10 minutes)



--
Stephane Moriaux et son [moins] vieux Mac


Reply With Quote
  #7  
Old   
Randy Webb
 
Posts: n/a

Default Re: javascript timer to cgi - 05-04-2006 , 10:20 PM



jason_box said the following on 5/4/2006 9:04 PM:
Quote:
button
onclick='var tmt = setInterval("doCallServer()",10*60*1000)'
start</button

button onclick='clearInterval(tmt)'
stop</button

Which part of the segment of code do I make the call to the cgi
program?
In the doCallServer() function.

Quote:
I was thinking of using general input forms and have it submit and post
to cgi, but that would still leave me with the timing issue.
No, setInterval sets that timer. Whether you had a timing issue or not
(and how you solved it) would depend on how you update the page.

Quote:
Also on another note, on this line

onclick='var tmt = setInterval("doCallServer()",10*60*1000)'

10*60*1000, what units is this in?
milliseconds and should probably be hard coded as 600000 instead of the
browser doing multiplication every time.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


Reply With Quote
  #8  
Old   
jason_box
 
Posts: n/a

Default Re: javascript timer to cgi - 05-04-2006 , 11:05 PM



Quote:
you'll need to create your function doCallServer()

i.e : to submit your form nammed 'myForm'

function doCallServer() {
document.forms['myForm'].submit();

}

I think I got a little confused with this. The javascript will handle
the timing of calling to the cgi script, so when the button is pressed,
it triggers the event to the cgi and the javascript can be made so that
it will call the script x-mount of minutes. Now I can see what the
doCallServer() would do, but I'm confused on why a
documents.form['myForm'].submit() would be needed? Wouldn't that mean I
have a form with data to pass to the cgi? In my case I have no data to
pass to the cgi, I only call to it and it does its job and I just need
to know the segment of code that will return the location of where the
output will be on the main index.html page. Thank you all again for
your time and explanations.



Reply With Quote
  #9  
Old   
Evertjan.
 
Posts: n/a

Default Re: javascript timer to cgi - 05-05-2006 , 04:05 AM



Randy Webb wrote on 05 mei 2006 in comp.lang.javascript:

Quote:
onclick='var tmt = setInterval("doCallServer()",10*60*1000)'

10*60*1000, what units is this in?

milliseconds and should probably be hard coded as 600000 instead of the
browser doing multiplication every time.

This multiplication is done only when clicked, so probably far less than
every 10 minutes. The setInterval() does not recalculate, but stores the
result, I presume.

For educational purposes, I prefer 10*60*1000 in this NG.

[As John Stockton so often remarked, 6e5 would be the best notation.]

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)


Reply With Quote
  #10  
Old   
jason_box
 
Posts: n/a

Default Re: javascript timer to cgi - 05-05-2006 , 01:14 PM



Thank you all for your help. That XMLHttpRequest() object is very
useful and I also used document.getElementById().innerHTML function
to specify where I wanted outputted instead of using iFrames. I've had
issues with iframes in the past, but they were useful for a site I
built a year back. Thanks again, I got my script to work perfect now.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.