Where is the actual payload (the form data) in the AJAX request; is it linked to the columns key?
Sep 24, 2020
28
Level 1
Ajax request error 422 (Unprocessable Entity)
Hey guys! I'm having issue with ajax request. I'm using jquery tabledit plugin and when saving edited row, facing error 422 (Unprocessable Entity) and in response text I get this error "{"message":"The given data was invalid.","errors":{"password":["New Password is required."]}}".
Here is my blade file. (after initiating table) jquery function
$.ajaxSetup({
headers: {
'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
}
});
$('#editable').Tabledit({
url: '{{ route("row_edit") }}',
dataType:"json",
type:"post",
editButton: true,
deleteButton: true,
columns: {
identifier: [10, 'id'],
editable: [[5, 'pcs'], [6, 'weight'], [7, 'rate']]
},
restoreButton:false,
onAjax: function(action, serialize) {
// Executed before the ajax request If returns false, does not send the ajax request. (v1.2.2)
console.log(serialize);
},
onSuccess:function(data, textStatus, jqXHR)
{
// Executed when the ajax request is completed
console.log(data);
console.log(textStatus);
console.log(jqXHR);
},
onFail: function(jqXHR, textStatus, errorThrown) {
// Executed when occurred an error on ajax request
console.log("error");
console.log(jqXHR);
},
});
on the controller side, I'm just returning same $request just to check wether the data is coming or not.
return response()->json($request);
Any help would be appreciated. Thanks in Advance
Please or to participate in this conversation.