Skip to main content
March 17, 2009
Answered

CFCONTENT from within any AJAX layout

  • March 17, 2009
  • 4 replies
  • 1673 views
CFCONTENT does not work as documented when I call it from within my AJAX app. Workarounds that call the code from another directory are way too kludgey for the client, but proved my standard code works outside of AJAX layout areas.

This problem was first mentioned here in January '07 but never answered. Has anyone found a workaround?

This topic has been closed for replies.
Correct answer
Thanks everyone, I made it work. Special thanks to Adam for the final hint.

I'm sure there are more elegant ways but here it is so far...

4 replies

March 18, 2009
>>> Make sense?

Totally. Or at least I'll find out if it did in a few minutes when I try the idea you just gave me. :)

I'll let you know, thanks.

Correct answer
March 18, 2009
Thanks everyone, I made it work. Special thanks to Adam for the final hint.

I'm sure there are more elegant ways but here it is so far...
March 17, 2009
Hi,

Thanks again for the speedy reply. I don't know the answer to that, but it also occurred to me that ColdFusion scripts are parsed multiple times before rendering, and to make regular HTML <script> containers work one wraps them in CFOUTPUT to delay the rendering and retain their variables. Maybe WDDX or some way to delay the output is required.

Cheers!
Inspiring
March 17, 2009
> hmm... a code sample will probably be good....

And possibly a description of what the problem actually is!

--
Adam
March 17, 2009
Thanks and apologies... I should have just said "CFCONTENT does not work when called from within any AJAX container," for example CFDIV, CFWINDOW, CFLAYOUTAREA.
According to this 2007 post by tSpark it applies to CFDOCUMENT as well: See CF8 - Ajax Form Post and Document Type

The code I'm now testing with is in a file named cfContentDisplay.cfm which is copied from the CFCONTENT example in the CF8 documentation, but I'm using my own query against my own datasource, and cfContent is itself a cfinclude on a template named fileDisplay.cfm. To launch it I have tried several variations on the theme: ColdFusion.navigate('file_display.cfm?nowrap=true&ext=xls&q=incList','docDisplayWindow',myCallBack,myErrorHandler,'post','sendIncompletesForm'); (I love this function because it's so easy to pass and retrieve a mixture of form and url variables.) The result is exactly as tSpark described... I see the HTML table in a standard browser window, it does not launch and display in Excel. The same code works as expected (and as I've used it repeatedly for at least 4 or 5 years) if it is in a non-AJAX page. That helps sometimes, but the current project is to be hosted on a server on which the app will have no access to anything outside its own directory, so I'm in need of a real fix.

I hope that's clear.

Inspiring
March 17, 2009
hmm... a code sample will probably be good....

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/