Solved

How do I use Ajax with Coldfusion 9 to dynamically display results of a SQL query?

Posted on 2010-11-27
3
627 Views
Last Modified: 2012-05-10
Hello

I have a cold fusion page that pulls data from a database table that updates regularly (Cisco Call Center table that tells me how many calls are holding). I want to have the database call results dynamically update on the web page that displays them.

I know that I can accomplish this with the language I am using (Coldfusion) and the AJAX integration it offers. I can't figure out starting point though. I am looking for code examples or direction to an example for this specific implimentation.
thanks

Erik
0
Comment
Question by:heliontech
3 Comments
 
LVL 18

Accepted Solution

by:
Plucka earned 167 total points
ID: 34223338
You can do a javascript timer that will fire ever X seconds and call the ajax

The ajax call will return the data and update the page

Here is a sample without the timer

http://tutorial13.learncf.com/
0
 
LVL 19

Assisted Solution

by:Bhavesh Shah
Bhavesh Shah earned 166 total points
ID: 34225348
0
 
LVL 1

Assisted Solution

by:sir-fal
sir-fal earned 167 total points
ID: 34538229
The easiest way is just to use a little bit of jQuery...

all you have to do is create a coldfusion page that lists all the calls (HTML) and then get it with a simple jQuery get()

the example will load the content of http://www.myServer.com/callList.cfm (it will refresh the data 250ms after it has been loaded; so it should always be up to date) into the div in the page... it's a super basic example... but enough to get you going :)

 
<html>
	<head>
		...
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
		<script type="text/javascript">
			$(document).ready(function(){
				setTimeout("loadCalls()",250);
			});
			
			function loadCalls() {
				var mySourcePage = "http://www.myServer.com/callList.cfm";
				$.get(mySourcePage,function(data){
					$("#callList").html(data);
					setTimeout("loadCalls()",250);
				});
			}
		</script>
		...
	</head>
	<body>


		.... 
		<div id="callList"></div>
		...
	</body>
</html>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

911 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

23 Experts available now in Live!

Get 1:1 Help Now