Solved

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

Posted on 2008-10-29
1
995 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:
Scott Bennett 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

19 Experts available now in Live!

Get 1:1 Help Now