Return JSON when the error happened in an XHR context