I'm using a formrequest file with laravel 5.2 to check input. This form i'm calling using jquery's $.post function. In my console, it's return 422 Unprocessable Entity which I suspect to be coming from the response since i'm not formatting it to json. One way of doing is this
I'd would like to know how I can invoke from my form request, the means to change the output messages to json.
Thanks!
UPDATE 1
JQuery looks like this:
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('input[name="csrf-token"]').val()
}
});
$("#changePassword").on('click', function(e){
e.preventDefault();
var data = {};
data.name = $("input[name='name']").val();
data.surname = $("input[name='surname']").val();
data._token = $('input[name="_token"]').val();
$.post('url',data).done(function(data){
$(".message").empty().html("Done!");
}).fail(
function(response, status){
}
);
});
$.postsection?