AJAX with Coldfusion 7
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>
John is a freelance programmer living in Sydney Australia. He blogs whatever takes his fancy; computing tips, travel letters, and random stuff from his life. He does it primarily to learn and demonstrate the running of a website.
Recent Comments