Currently I use this to display validation errors via ajax:
if (data.validation_failed == 1)
{
var arr = data.errors;
Try this code. It works well:
$.ajaxSetup({
headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}
});
$("#sendData").submit(function(e)
{
e.preventDefault();
var formData = new FormData(jQuery('#sendData')[0]);
$.ajax({
type:'POST',
url:"/your(URL)",
data:formData,
contentType: false,
processData: false,
success:function(data)
{
alert(data);
},
error: function(xhr, status, error)
{
$.each(xhr.responseJSON.errors, function (key, item)
{
$("#errors").append("- "+item+"
")
});
}
});
});