I'm using a JavaScript plugin to upload files to a ColdFusion app. It uses AJAX to communicate with the server and expects JSON in return. (pretty standard) I have two cfm scripts.
The first contains the form for the plugin.
The second handles the actual uploading, deleting, returning file lists, etc.
The second script returns JSON as plain text for the plugin to process.
The second script renders no HTML and the JSON sent back to the first script is fed straight into the js plugin.
Everything works perfectly actually. I've gotten it to upload files and return file lists.
my problem: As the second script's code gets more complicated it's getting much harder to debug.
It renders no code, so cfdump is useless.
I'm poking around in the dark with no error messages or other info to let me know why something isn't working.
my limitations: The plugin is large and complicated and I don't want to mess with it if I don't have to. And I shouldn't have to mess with it because it works perfectly, it's my cf code that's the problem.
I also don't have access to the admin area for this project.
But I need some way to log or debug this code.
my solutions: I've been doing cfdump to a third file, but this is a less than ideal solution as I'm spending half my time coding and half my time changing the cfdump solution to suit new needs. And also evolving my cfdump logger to handle different situations. I don't want to reinvent the wheel by writing my own logger though, I just want to code. I got my admin to install the AJAX logger not realizing it's meant to log JavaScript, not ColdFusion. So that's not working either.
I know that people have worked with ColdFusion for AJAX. I can't be the only one having this problem. Any help is appreciated.
Don't forget the simple and powerful <cflog>
tag. You can dump variables at any point in your code and if you want to dump a structure, you can use serializeJSON(someStruct)
to see the entire structure (or object converted to a structure) in your logs. Combine that with the tail view in Eclipse/CFBuilder, and you have a real-time stream of the inner workings of your non-HTML generating code.