Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2010-11-27
3
Medium Priority
?
637 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
[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
3 Comments
 
LVL 18

Accepted Solution

by:
Plucka earned 668 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 664 total points
ID: 34225348
0
 
LVL 1

Assisted Solution

by:sir-fal
sir-fal earned 668 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

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 …
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 …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

609 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