?
Solved

Coldfusion 8 Ajax Timer

Posted on 2007-11-16
12
Medium Priority
?
1,097 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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
Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

 
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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

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…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
Suggested Courses

752 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