We have a PHP service where we throw a custom Exception object (simply has a message property) . These are caught in PHP and then we do the following:
header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request', true, 400);
This causes two things:
1) A console error if their console is up
2) The error() callback and .fail() on a deferred object to be invoked.
We want 2 without the side-effect of 1. If we set the error code to 200, only success() and then() is invoked.
Is there any middle ground we can use?
Correction, my first answer was bullcrap.
if(!window.console) console = {log: function() {}};
This is the way to go. Use this before the $.ajax
call (or however you do the ajax request).