Because blob is returned in the response (responseType = blob
). Additionally, you need to process this blob (so it still contains an error message).
To do this, you can use the built-in browser object of type FileReader
(it can read data from Blob (and from File, too)) and its API:
webix.attachEvent("onAjaxError", function(xhr){
const reader = new FileReader();
let response;
reader.onloadend = (e) => {
response = JSON.parse(reader.result);
console.log(response);
}
reader.readAsText(xhr.response); //read the data as a text string with the given encoding (utf-8 by default)
if(xhr.status===500){
webix.message({type: 'error', text:"Please try again"});
}
});