I have a Controller that is returning errors like this:
return response()->json(['erros' => $this->renderHttpException($e)]);
I'm getting this json as a response to the ajax request:
{"email":["The email field is required."],"telefone":["The telefone field is required."]}
I need to list these errors in a div, without having to specify each field as I did with the email, how do I?
function Create(id, url) {
$.ajax({
url: url,
data: $('#' + id).serialize(),
dataType: 'json',
type: 'POST',
error: function (data) {
var errors = data.responseJSON;
document.getElementById('message').innerHTML = errors.email;
}
});
}