Is there a way to make onrequestend.cfm call conditional. i.e if I call a template through ajax, I don't want that onrequestend.cfm should be executed on ajax requests.
As in my case this is generating some header info like meta tags etc.
Is there a way to make onrequestend.cfm call conditional. i.e if I call a template through ajax, I don't want that onrequestend.cfm should be executed on ajax requests.
As in my case this is generating some header info like meta tags etc.
There is not that I am aware of. However if you place all the templates you will be calling in a sub-directory and place a blank onRequestEnd.cfm in the sub-directory that should give you the same effect.
You have a few options:
onRequestEnd()
event instead of onRequestEnd.cfm; and inside your onRequestStart()
event method, tell ColdFusion not to do anything for the onRequestEnd event.Since you didn't specify, I'll guess and say that your AJAX requests use a CFC, like so:
/foo/bar.cfc?method=getSomething¶m=value
In which case, you can easily identify all requests being routed to a CFC like this:
function onRequestStart(targetPath){
if (listLast(arguments.targetPath, ".") eq "cfc"){
structDelete(this, "onRequestEnd");
}
}
Note that the function is only deleted for the current request, so you don't have to worry about it not being there for future requests. It will be.