Troubleshooting & How-Tos 📡 🔍 Programming

Empty AJAX Replies Working on ColdFusion But Not Lucee

This is very much a corner case on top of another corner case, but on the off-chance someone else encounters the same issue, I hope this makes it easier for you to fix it.

So. I was fixing a legacy web application that uses jQuery to make remote API calls. The API would return an empty 200 OK if it was successful, and a 400 error if it failed.

It worked fine on the old Adobe-brand ColdFusion server…but not on a newer server running Lucee. Despite the fact that the Lucee box was also returning a 200 OK. The jQuery handler just never fired!

OK, fine, Lucee isn’t exactly the same CFML implementation as any particular version of ColdFusion. So I dug through the code. And I dug through the browser developer tools. And I added an error handler and logging. (The old code only cared about the success case, so it seemed like a good time to update it.)

The only difference I found was that Lucee was sending the empty response as text/xml rather than text/plain.

Now you’d think that with an empty response, the content-type wouldn’t matter, right? Wrong. jQuery was seeing the text/xml type and trying to parse the void as XML! :facepalm:

All because two CFML implementations had different defaults for the content-type on an empty response.

Solution: Add returnformat="plain" to the function that returned the void took care of the problem.