Solved

Having an ajax call return the query result from a coldFusion function call

Posted on 2008-10-29
1
977 Views
Last Modified: 2013-12-24
How do i define an ajax call that calls the function below and stores the result in a variable.

 This function is located in a separate file called getOfferCreatives.cfm
<cffunction name="getCreatives" output="false" returntype="query" hint="Returns a query of the Creatives">

	<cfargument name="Offer_ID" required="yes" type="numeric" hint="The offer ID of the items to return">

		<cfset var OCreatives="">

		<cfquery datasource="PP" name="getOfferCreatives">

			SELECT Creative_ID

			      ,CreativeName		   

			     -- ,CreativeFileName

			      ,CreativeDesc

			      ,CreativeNote

			      ,CreateEmployee_ID

			      ,CreateDateTime

			      ,Offer_ID

		 	FROM Creatives (nolock)

			WHERE Offer_ID = <cfqueryparam cfsqltype="cf_sql_numeric" value="#ARGUMENTS.Offer_ID#">

		</cfquery>

	<cfreturn OCreatives>

</cffunction>

Open in new window

0
Comment
Question by:onaled777
1 Comment
 
LVL 14

Accepted Solution

by:
SBennett earned 250 total points
ID: 22834358
You would use CFAjax Proxy to establish a connection to the cfc that contains your function
http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_a-b_3.html#3983510

Then you write a javascript that insantiates the proxy object, calls the function and has a callback handler to  do whatever you need to do with the query results. There is an example at the bottom of the documentation that does exactly what you are trying to do.
0

Featured Post

Scale it in WD Gold

With up to ten times the workload capacity of desktop drives, WD Gold hard drives employ advanced technology to deliver among the best in reliability, capacity, power efficiency and performance.

Join & Write a Comment

Suggested Solutions

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

17 Experts available now in Live!

Get 1:1 Help Now