Solved

Coldfusion 8 Ajax Timer

Posted on 2007-11-16
12
1,092 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 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
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

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.

Question has a verified solution.

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

Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
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 make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to insert an Iframe into 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 : Open Page or Post…

730 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