I have a Form in Laravel that submits with Ajax.every thing works well but the problem is that I can't render the validation's errors in HTML.
(I want to display the errors in <ul><li> in my HTML)
Here is my Ajax request:
$(document).ready(function () {
$("#submit").click(function (xhr) {
xhr.preventDefault(),
$.ajax({
type: "POST",
contentType: "charset=utf-8",
dataType: 'json',
url: "{{route('messages.store')}}",
headers: {
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content")
},
data: {
name: $("#name").val(),
email: $("#email").val(),
phone: $("#company").val(),
subject: $("#subject").val(),
message: $("#message").val()
},
success: function () {
alert('True');
},
error: function (xhr) {
console.log((xhr.responseJSON.errors));
}
}, "json")
})
});
Console logs:
Thanks for any help.
