in laravel controller I am sending the validation error to a ajax request by a code like that
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails())
{
$data = array('errors' => $validator->errors()->toArray());
return Response::json($data);
}
Now in receive by ajax I want it (the validation error) to impress the text area and error display div. For that I am doing this .
bla bla blaala
success:function(data, textStatus, xhr, error){
if(data == "OK")
{
$('div.result').html('You have successfully posted ! Please refresh to see your post <hr/>');
//window.location.reload(true);
}
else
{
// $('div.arr').data(data.errors);
//alert("---"+data);
$('div.result').html('Your post can not be possible ! Please check the text bOx ! <hr/> ');
$('div.arr.errors').val(data.errors);
$("#ask").attr("disabled", false)
}
I want to get the effect on this
<div class="arr control-group{{ $errors->first('about', ' has-error') }}">
but only the
<div class="result" style="color:red;">
</div>
is working during the error.
how does the errors can be collected and shown in the view ?
thank you in advance \m/