The below code snippet explains how to convert jQuery AJAX response.responseText string to JSON object in the jQuery.ajax error handler
<script type="text/javascript">
$.ajax({
type: "POST",
url: "<URL>",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
},
error: function (response) {
var responseTextObject = jQuery.parseJSON(response.responseText);
}
});
</script>
Above I have used jQuery.parseJSON method to convert the jQuery AJAX response.responseText string to JSON object