Fixes bug where setting statusCode doesn't work for AJAX handlers