In one of my recent project, at most of the occasions I was using Ajax and ColdFusion CFC to get the records from DB. But in some cases, in my local development server, I was facing some problems, while in the production server all were working fine. The difference I found only that I had enabled my ColdFusion Debugging in my local development server.Once I disabled that all seemed to be OK.
The main problem was that at the time of Ajax call I was expecting the response text as a JSON format from my CFC, so I set the return type of the Ajax call as ‘JSON’ type.
Like here I am using the jQuery AJAX call.
$.ajax({ url: pagePath, data: pageData, dataType: 'json', success: function(data) { }, error: function(data) { } });
But as my ColdFusion debugger was enabled, ColdFusion appended extra debugging information(which was not in a JSON format) to my response text and the return format was not staying in ‘JSON format’. That was why the Ajax callback was going to the error block even if my server response was successful(as I found in the Firebug). Once I disabled my ColdFusion debugger ColdFusion stopped adding debugging information and I got my ‘JSON format’.
So be careful with the ColdFusion debugger while working with Ajax response.