I have ajax method. I send a request. if a error is recieved, its caught by error: function(data) {
How do i obtain the error message received? front my google chrome,network i can see message received as:
how do i extract the 'message
element?
From the back end , i throw error messages like
throw new Exception("There is already a user registered with the email provided");
In chrome i see:
error:"Internal Server Error"
exception:"java.lang.Exception"
message:"There is already a user registered with the email provided"
path:"/registerAccountant"
status:500
timestamp:1523286158171
how do i extract that error message?
Below is my code to send and recieve
$.ajax({
type: accountantRegistrationForm.attr('method'),
url: accountantRegistrationForm.attr('action'),
data: fd ,
contentType: false,
processData: false,
success: function(data) {
$('#accountantSubmitBtn').attr('disabled', false);
//resetJournalEntryTable();
setTimeout(function(){
$.toast({
text: 'New Accountant successfully saved.!',
showHideTransition: 'fade',
hideAfter: 2000,
bgColor: '#3b78e7',
textColor: '#fff',
allowToastClose: false,
position: 'top-center',
icon: 'success',
loader:false
});
$('body').loading('stop');
/*$('html, body').scrollTop(0);*/
}, 500);
//$('#jedatatable').DataTable().ajax.reload();
},
error: function(data) {
setTimeout(function(){
$.toast({
text: 'Accountant Registration failed.1 !',
showHideTransition: 'fade',
hideAfter: 2000,
bgColor: '#3b78e7',
textColor: '#fff',
allowToastClose: false,
position: 'top-center',
icon: 'error',
loader:false
});
$('body').loading('stop');
/*$('html, body').scrollTop(0);*/
}, 500);
$('#accountantSubmitBtn').attr('disabled', false);
$('body').loading('stop');
},
});