Using ajax I am updating some value and in response I am showing toaster red (for error) and green (for success) but problem is that if there is error it always shows green toaster. I want a red toaster on error here is my code which I already tried
js
success: function (data) {
toastr.success(data.message);
},
error: function(err) {
toastr.error(err.message);
}
controller
if (some condition){
$customer->save();
return response()->json([
'success'=> true
'message' => 'User status updated successfully.'
]);
} else {
return response()->json([
'error'=> true,
'message'=> 'Visit Failed distance is too long'
]);
// this should be red toast but it green
}
Please read comment on above code // this should be red toast but it greencan someone help me how I can show red toaster on error?