Displaying Ajax data and using timers properly



Hi Guys,

I'm new to Javascript and have a couple of questions that I hope
someone could quickly answer for me.

First, I'm trying to modify an example Ajax script to fit my needs.

The script is located here:

http://ajaxify.com/run/time/periodicRefresh/

I'm trying to display return data from my existing script, and I'm a
little confused on how to display the returned variables within my Web
page. Currently the author of the 'example' script has the following
code embedded within the HTML:

<form action="/">

<div id='customTimeLabel' class='timeLabel'></div>

<div align="center">
<input type="hidden" id="customTime" value="Refresh" />
</div>

</div>
<div align="center"></div>

</form>

The author displays this form and also has a button to create an
additional action when the button is pressed. I removed the button and
just want to display the variables, I do not want to have a form as he
did. Is there a alternate way of doing this? When I embed this in my
code it takes up too much real estate on the Web page.


Second, there is a setInterval timer used that periodically goes to
the server and refreshes the data. I have created a function,
'volup()' that stops the timer 'clearInterval(interval)' and displays
a new message for a few seconds, then my script is supposed to restart
the setInterval timer. Everything seems to work ok with the exception
of the setInterval restart. Could someone have a look at my code and
give me some suggestions? The problem is on the last line of the
volup() function, this command never seems to restart the timer. Also
I've noticed that my setTimeout timer can become very erratic at
times, not following my specified timing of 3 seconds, but this only
happens once in a great while and is very intermittent.

Thanks in advance,

Shawn


ajaxCaller.shouldDebug = false;
var timeURL = "cgi-bin/test?h=1";
//var timeURL = "tickercontent.txt";
window.onload = function() {
// $("defaultTime").onclick=requestDefaultTime;
// $("customTime").onclick=requestCustomTime;
requestCustomTime();

interval=setInterval(requestCustomTime, 1500);
}

function volup(){

clearInterval(interval)
showCustomTime("Change Source", "");

a="requestCustomTime();"

setTimeout(a, 3000);
clearTimeout(t)

interval=setInterval(requestCustomTime, 1500)

}

function requestCustomTime() {
var callingContext = Math.round(Math.random() * 100);
ajaxCaller.getPlainText(timeURL, showCustomTime);


}

function showCustomTime(text, callingContext) {
var customTimeLabel = $("customTimeLabel");
customTimeLabel.innerHTML = text + "." + callingContext;
}

.



Relevant Pages

  • Re: Restarting Pcs
    ... The script called "wait.ipf" works ... fine though timer is visible. ... "Terry M" escribió en el mensaje ... I thought you just wanted it to restart after 5 min. with no ...
    (microsoft.public.sms.installer)
  • Re: Bit Twister: Is this the dhclient-exit-hooks you were talking about?
    ... If you are running the dhclient then all you have to do is ... create the hooks script with YOUR CODE. ... DNS server with my wgets and then restart my firewall. ... You can put an echo statement on commands to show you what will happen ...
    (alt.os.linux)
  • Using VBScript to refresh group policy, restart, and log in.
    ... I am writing a script that needs to apply the domain's group policy, ... clearing the legal message text and ... after I restart the account's name goes back to ...
    (microsoft.public.windowsxp.general)
  • Re: Yes
    ... You set the timer interval, ... The conventional way of doing this would be to write a wscript class, and then give a reference of the class to the script control. ... Public Property Let Parent ... Public Property Get CreateObject(vProgID As Variant, Optional vPrefix As Variant = "") As Object ...
    (microsoft.public.scripting.wsh)
  • Using VBScript to refresh group policy, restart, and log in.
    ... I am writing a script that needs to apply the domain's group policy, ... clearing the legal message text and ... after I restart the account's name goes back to ...
    (microsoft.public.scripting.vbscript)