coldfusion built-in ajax calls

For the past two days, I have been getting this error coming back from a ColdFusion.navigate() call. It comes back in an annoying JavaScript alert box like this:

Error processing JavaScript markup for element myDiv: [Enable debugging by adding 'cfdebug' to your URL parameters to see more information]

Okay. So I go to the CF Admin and turn on "Enable AJAX Debug Log Window". I think add "cfdebug=1" on my url. I still get the JavaScript alert box telling me I still have an error, and I don't see the nice debugger in my browser either. I really have no idea why this isn't working, and if someone can shed some light on this, please let me know. But for now, that is not the subject of my post today.

Anyway, I found out why I kept getting that error! In one of my rendered files (display.cfm) I had some JavaScript code in a set of <script> tags, like this:

<script>
var myFunc = function() {
//JS code here }
</script>

I started removing pieces of the display to see where the error was. This was after I stopped banging my head on the desk. What I found was that if that JavaScript code was not in there, the error went away. So I tried to do a JavaScript include like this:

<script src="/path/to/js/file/display.js" type="text/javascript"></script>

Well, no more error, but the JavaScript did not execute when the rendered page loaded. So I went to the ColdFusion.navigate documentation and saw that it has a parameter named "callbackhandler". This parameter names a JavaScript method you can call after the page loads. So I created a new displayCallbackHandler() method and it looked something like this:

var displayCallbackHandler = function() {
//JS code here {

It worked! No more JavaScript alert box from ColdFusion, the JavaScript I had in the displayCallbackHandler method executed!

Comments
ffelknir znarf's Gravatar Make sure that the IP address of the system where you will be doing the debugging is included on the ColdFusion Administrator > Debugging & Logging > Debugging IP List page of the ColdFusion Administrator. By default this list includes only 127.0.0.1.
# Posted By ffelknir znarf | 2/3/08 9:44 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.7.002.