Solved

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

Posted on 2008-10-29
1
1,043 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
[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
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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

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

Today I am discussing AJAX problems in IE7 and I bet this will helps many guys out here who have problems with AJAX work. Lets start with the discovery of problem and then we will talk about its different solutions. My last two projects included …
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

752 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