Solved

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

15 Experts available now in Live!

Get 1:1 Help Now