Refactor output of AJAX request errors.