I want the user to be notified when there is a validation error from php. i am using laravel 5.3 to create the form and Ajax to get the error message.
here is my JavaScript code
$.ajax({
url: '/artistPost',
type:'POST',
data: {
_token: Artisttoken,
Name: Name,
Phone: Phone,
},
error:function (data, response, xhr, status, error) {
var errors = data.responseJSON;
console.log(errors);
}
this is what i am seeing in the Network section of the Chrome deveper tools
<?php{"name":["The name field is required."],"phone":["The phone field is required."]}
and this is what I am seeing in the console
Update
this is from the controller
public function create(ArtistRequest $request){
dd($request->all());
return redirect()->back();
}