Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1105
  • Last Modified:

Coldfusion 8 Ajax Timer

Anyone know of a way to generate a timer or ontick event in coldfusion?

For example I have a a couple of cfdivs that need to update every 10 seconds.

I used to be able to this in .NET easily with a timer and an ontick event, but does coldfusion have anything similiar?
0
Matt Grofsky
Asked:
Matt Grofsky
  • 5
  • 5
  • 2
1 Solution
 
PluckaCommented:
Just use a javascript timer to do this.

0
 
Matt GrofskyAuthor Commented:
Do you have any examples?
0
 
PluckaCommented:
Sure,

What do you want to do when the timer hits, refresh a page, a section etc, etc. If you give me an idea, i'll post some working code.

This code will refresh the page every 3 seconds
<html>
<head>
<title>Refresh</title>
<script language="JavaScript">
<!--
function refreshIt() {
window.location = 'http://yoursite.com'
}
//-->
</script>
</head>
<body onload="timer=setTimeout('refreshIt()',3000)">
<p>see this page refresh itself in 3 secs.<p>
</body> 

Open in new window

0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
PluckaCommented:
Sorry, add a

timer = null

before the function statement on line 6
0
 
Matt GrofskyAuthor Commented:
Basically just refresh a cfdiv every 10 seconds.
0
 
PluckaCommented:
Well that example can do that.

Just change the 3000 to 10000 to make it 10 seconds.

and change the windown.location to something like

document.divname.innerHtml = 'New Content'; Of course it depends on what is in the div, if that is something from an external source, then you need to use ajax.
0
 
Matt GrofskyAuthor Commented:
well ya cfdiv is ajax, but I defintiely get the gist of it.

What I ended up doing was

<script>
function updatestats() {
   ColdFusion.navigate(GetData.cfm',GetDataNow);
   window.setTimeout('updatestats()',15000);
}
</script>

<body onload="window.setInterval('updatestats()',15000)">

<cfdiv bind="url:GetData.cfm" style="display: inline; width: 20px" id="GetDataNow"></cfdiv>

Thanks for getting me in the right direction.
0
 
PluckaCommented:
Ahh,

Yes easy in CF8, you should have mentioned you were using Version 8, glad you got it sorted.
0
 
Matt GrofskyAuthor Commented:
minor detail  :-P
0
 
_agx_Commented:
>  window.setTimeout('updatestats()',15000);

Michin,

If you're using setInterval() onload you shouldn't need to call setTimeout() too.
0
 
Matt GrofskyAuthor Commented:
oops ya forgot to take out that line of code before O posted
0
 
_agx_Commented:
Ok, good :)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now