1

When I set a cffunction's access to remote--so I can call it through AJAX--the call returns the HTML I have in my Application.cfm template.

Is there any way around this, or do I have to move the HTML out of Application.cfm?

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Timothy Ruhle
  • 7,387
  • 10
  • 41
  • 67

1 Answers1

5

This would be considered expected behavior. I'd suggest not outputting content within your Application.cfm. Consider using custom tags for wrapping your pages or better yet switch to using Application.cfc and use custom tags.

Todd Sharp
  • 3,207
  • 2
  • 19
  • 27
  • Thanks Todd. I was wondering if this was expected, even though if you change it from remote to something else it doesn't include that stuff. – Timothy Ruhle Feb 28 '11 at 04:12
  • The difference is not in the access type you've set, but in the way you're calling the CFC. If you set it to access="remote" and call it via ajax, you're creating a new HTTP request. Every HTTP request will execute Application.cfm first, which is why you're getting that output. If you have a CFC set to public, then you're calling it from a cfm file that's already run the Application.cfm code during the initial HTTP request. – Dan Short Feb 28 '11 at 12:43
  • http://www.bennadel.com/blog/1647-Learning-ColdFusion-9-Application-cfc-OnCFCRequest-Event-Handler-For-CFC-Requests.htm – Henry Feb 28 '11 at 19:14