Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1068
  • Last Modified:

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

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
onaled777
Asked:
onaled777
1 Solution
 
Scott BennettCommented:
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now