Solved

Coldfusion 8 Ajax Timer

Posted on 2007-11-16
12
1,089 Views
Last Modified: 2013-12-20
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
Comment
Question by:Matt Grofsky
  • 5
  • 5
  • 2
12 Comments
 
LVL 18

Expert Comment

by:Plucka
ID: 20310015
Just use a javascript timer to do this.

0
 
LVL 2

Author Comment

by:Matt Grofsky
ID: 20329027
Do you have any examples?
0
 
LVL 18

Accepted Solution

by:
Plucka earned 500 total points
ID: 20331066
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 18

Expert Comment

by:Plucka
ID: 20331068
Sorry, add a

timer = null

before the function statement on line 6
0
 
LVL 2

Author Comment

by:Matt Grofsky
ID: 20341780
Basically just refresh a cfdiv every 10 seconds.
0
 
LVL 18

Expert Comment

by:Plucka
ID: 20341885
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
 
LVL 2

Author Comment

by:Matt Grofsky
ID: 20343189
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
 
LVL 18

Expert Comment

by:Plucka
ID: 20344102
Ahh,

Yes easy in CF8, you should have mentioned you were using Version 8, glad you got it sorted.
0
 
LVL 2

Author Comment

by:Matt Grofsky
ID: 20344497
minor detail  :-P
0
 
LVL 52

Expert Comment

by:_agx_
ID: 20361354
>  window.setTimeout('updatestats()',15000);

Michin,

If you're using setInterval() onload you shouldn't need to call setTimeout() too.
0
 
LVL 2

Author Comment

by:Matt Grofsky
ID: 20361465
oops ya forgot to take out that line of code before O posted
0
 
LVL 52

Expert Comment

by:_agx_
ID: 20361539
Ok, good :)
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question