Check for remote CFC call in CF 8
Is there a way, in CF 8, to determine if the current request is calling a CFC that has access=remote? Basically, I'd like to mimic CF 9's onCFCRequest() method, but only for remote methods. I spent a good portion of yesterday afternoon trying to figure out why my jQuery AJAX call would work for me locally, but break on our staging site. All code was identical in every comparison, and both sites were using the same database so the data was identical as well. Long story short, our staging server had CF debugging turned on, and it was appending the debug info to the end of the json being returned from my CFC call, which then threw errors in jQuery. Locally I have debugging going to ColdFire/Firebug, so I never saw the problem. Anyway, a simple cfsetting showdebugoutput=false fixed the issue. So, rather than having to remember to use cfsetting for every remote method, is there a way I can programmatically figure out if the current request is calling a remote method in CF 8? -- Thanks, Eric Cobb ECAR Technologies, LLC http://www.ecartech.com http://www.cfgears.com ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334572 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Check for remote CFC call in CF 8
specifically for detecting jquery ajax calls to remote cfc functions you can use something like this: cfset headers = getHttpRequestData().headers cfif structKeyExists(headers, X-Requested-With) AND headers[X-Requested-With] eq XMLHttpRequest it's an ajax request using jquery! /cfif more reading: http://www.insideria.com/2009/04/jqueryserver-side-tip-on-detec.html http://blog.pengoworks.com/index.cfm/2009/4/9/ColdFusion-UDF-for-detecting-jQuery-AJAX-operations unfortunately, cf's built-in functions performing ajax requests do not append any headers, so you can't detect those... well, without hacking the cfajax.js file... which is not a very good idea... Azadi On 15/06/2010 22:18, Eric Cobb wrote: Is there a way, in CF 8, to determine if the current request is calling a CFC that has access=remote? Basically, I'd like to mimic CF 9's onCFCRequest() method, but only for remote methods. I spent a good portion of yesterday afternoon trying to figure out why my jQuery AJAX call would work for me locally, but break on our staging site. All code was identical in every comparison, and both sites were using the same database so the data was identical as well. Long story short, our staging server had CF debugging turned on, and it was appending the debug info to the end of the json being returned from my CFC call, which then threw errors in jQuery. Locally I have debugging going to ColdFire/Firebug, so I never saw the problem. Anyway, a simple cfsetting showdebugoutput=false fixed the issue. So, rather than having to remember to use cfsetting for every remote method, is there a way I can programmatically figure out if the current request is calling a remote method in CF 8? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334576 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Check for remote CFC call in CF 8
Just to be clear - checking the header works when the library used for calls uses it. It's not 100% correct (but speaking practically, it is safe). On Tue, Jun 15, 2010 at 10:23 AM, Azadi Saryev azadi.sar...@gmail.com wrote: specifically for detecting jquery ajax calls to remote cfc functions you can use something like this: cfset headers = getHttpRequestData().headers cfif structKeyExists(headers, X-Requested-With) AND headers[X-Requested-With] eq XMLHttpRequest it's an ajax request using jquery! /cfif ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334578 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm