Trace and ajax in CF9
I was having an issue with an ajax call failing. Of course I thought there was something wrong in the cfc so I added a few more trace statements which didn't help. I finally decided to examine the stacktrace and it pointed (eventually) to the line where the trace occured. I removed that trace and the exception moved to the next trace line. I know I may be in the slow group but I see a pattern here. After removing all the trace statements the code worked fine.
It is a bit ironic that one's first impulse is to add some trace statements to troubleshoot which only exacerbates the problem!
Changing the inline attribute to false had no effect.
If you uncheck the debug setting: "Enable request debugging output" in CFAdministrator the ajax call works fine but the output from the trace is not written to the trace.log file
If you surround the trace with a try catch you will see the exception message is: Variable DEBUGGER is undefined.
Code to duplicate: testtrace_cfc.cfc
component {
remote string function doesitfail( String input)
returnformat="JSON" {
try{
trace( text="#arguments.input#" inline="false" );
writelog( file="mylog" text="#arguments.input# was entered");
}
catch( any ex){
writelog(file="mylog" text="#ex.message#");
}
return ucase(arguments.input);
}
}
Calling Template:
<cfparam name="url.inString" default="No input">
<cfajaxproxy cfc="com.vawter.testtrace_cfc" jsclassname="testTrace">
<script language="JavaScript" type="text/javascript">
oT=new testTrace();
oT.setCallbackHandler(successh);
oT.setErrorHandler(errorh);
function successh(data){
alert(data);
}
function errorh(data){
alert("failed "+data);
}
</script>
<cfoutput><a href="##" onclick='oT.doesitfail("#url.instring#");return false;'>click me</a></cfoutput>
For the above code the ajax call succeeds because the exception is caught and the return statement is executed despite the error.
Workaround:
Use writelog instead of trace
The problem also occurs in CF8.
