Solved

Coldfusion 8 Ajax Timer

Posted on 2007-11-16
12
1,093 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
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…

688 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