Currently I use this to display validation errors via ajax:
if (data.validation_failed == 1)
{
var arr = data.errors;
I handled it using this way for laravel 5.5
Html code
" required="required">
{!! $errors->first('mandapName', ':message') !!}
Controller validation code
// Validate form data
$validatedData = request()->validate([
'mandapName' => 'required',
'location' => 'required',
'landmark' => 'required',
'description' => 'required',
'contactNo' => 'required',
'slug' => 'required',
'functional' => 'required'
]);
And in javascript
$.ajax({
//.....Your ajax configuration
success: function (data) {
// Success code
},
error: function (request, status, error) {
$('[name="mandapName"]').next('span').html(request.responseJSON.errors.mandapName);
//.......
}
});