Solved

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

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

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…
PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

776 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