Solved

Coldfusion 8 Ajax Timer

Posted on 2007-11-16
12
1,084 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:Michin
  • 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:Michin
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
 
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:Michin
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 2

Author Comment

by:Michin
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:Michin
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:Michin
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure (http://www.axure.com/). It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now