Solved

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

Posted on 2010-11-27
3
632 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

685 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