i want to show toaster on success or failer so i tried this code
$.ajax({
type: "GET",
dataType: "json",
url: '{{ route('users.update.visit_clear') }}',
data: {'visit_clear': visit_clear, 'user_id': userId , 'location': location , 'cs_location': cslocation },
success: function (data) {
if (data.message != ""){
toastr.success(data.message);
}
}
error: function (data) {
toastr.error(data.message1);
}
});
and in controller i have condition
if($var <= 1){
return response()->json(['message' => 'User status updated successfully.' ]);
}
else{
return response()->json(['message1' => 'Visit Failed Distance is too long' ]);
}
if i use error:function it doesnot response me