Archive

Posts Tagged ‘coldfusion’

AJAX with Coldfusion 7

June 25th, 2008

I’m trying to do some ajax with Coldfusion 7.
Anything returned from a call to a CFC method gets wrapped in a wddxPacket

<wddxPacket version=’1.0′><header/><data><string>This is the return value>/string></data></wddxPacket></code>

There is no way to avoid it. What were they thinking?!

The solution is simply not to use a CFC… instead write a standard coldfusion which parses the url for your method name and returns the data you want. Don’t forget to astudiously go around squashing all the whitespace CF likes to generate. And put special traps into your application.cfc to omit any standard headers/footers. And…

The one thing consistent about CF has always been the complete absence of foresight.

Here’s my dirty workaround: “ajax.cfm”
See the comments for a much improved version!

<cfparam name="method">

<cftry>
	<cfoutput>#evaluate(method & "()")#</cfoutput>
	<cfcatch></cfcatch>
</cftry>

<cffunction name="hello"><cfsilent>
	<cfscript>
		return "hollow ddorld";
	</cfscript>
</cfsilent></cffunction>