Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > javascript timer to cgi

Reply
Thread Tools

javascript timer to cgi

 
 
jason_box
Guest
Posts: n/a
 
      05-04-2006
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
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      05-04-2006
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
 
 
 
 
jason_box
Guest
Posts: n/a
 
      05-04-2006
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:
> 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
 
Evertjan.
Guest
Posts: n/a
 
      05-04-2006
jason_box wrote on 05 mei 2006 in comp.lang.javascript:

> 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
 
jason_box
Guest
Posts: n/a
 
      05-05-2006
> <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

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


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

Thank you.

 
Reply With Quote
 
ASM
Guest
Posts: n/a
 
      05-05-2006
jason_box a écrit :
>><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();
}

> 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>

>>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
 
Randy Webb
Guest
Posts: n/a
 
      05-05-2006
jason_box said the following on 5/4/2006 9:04 PM:
>> <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.

> 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.

> 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
 
jason_box
Guest
Posts: n/a
 
      05-05-2006
>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
 
Evertjan.
Guest
Posts: n/a
 
      05-05-2006
Randy Webb wrote on 05 mei 2006 in comp.lang.javascript:

>>> 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
 
ASM
Guest
Posts: n/a
 
      05-05-2006
jason_box a écrit :
>>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.


I have a little problem with your deal :
"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"
here ___________________________________________^^^^^^^ ^^^^^^^^^^^^^^

As I unterstand your cgi loads back same page (with some adds on?)
On each new load the previous Javascript is forgotten ...

If you need a JavaScript to update sequentially a page, this page has to
be displayed in an other viewport (window or frame or iframe).

You may also use XMLHttpRequest to modify (on the fly) a part of your
page but this way of doing is not very easy, overall if you aren't
familiar with JavaScript.

ask XMLHttpRequest to Google

> Now I can see what the
> doCallServer() would do, but I'm confused on why a
> documents.form['myForm'].submit() would be needed?


That is an answer to your precedent post where you talk about form.

> 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


To call it you need a button with an onclick or a link or an action's
form, no ?

> 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.



<html>
<h1>my main page</h1>
<form>
<input type=button name="start" value="Start"
onclick="if(parent.myFrame)
tmp=setInterval('parent.myFrame.location=\'/cgi/foo.cgi\'',600000);
else alert('browser non compatible');
this.disabled=true;
stop.disabled=false;
">
<input type=button name="stop" value="Stop" disabled
onclick="clearInterval(tmp);
this.disabled=true;
start.disabled=false;">
</form>
<iframe name="myFrame" src="/cgi/foo.cgi" width=500 height=400>
Your browser doesn't know iframes, click <a href="/cgi/foo.cgi">here</a>
</iframe>
</html>

--
Stephane Moriaux et son [moins] vieux Mac
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I know about the shutdown timer, is there a "switch on" timer... Mal Carter Computer Support 3 01-12-2008 01:58 AM
page timer, or redirect timer Simon ASP .Net 1 11-04-2005 07:14 PM
System.Timers.Timer/System.Threading.Timer Not Firing At All on Dev Server james.e.coleman@gmail.com ASP .Net 1 02-22-2005 09:41 PM
System.Timers.Timer vs. System.Threading.Timer Kelsang Wangchuk ASP .Net 0 07-31-2003 04:28 PM
Re: CGI Perl "use CGI" statement fail Jürgen Exner Perl 0 07-31-2003 02:00 PM



Advertisments