maan56
4 weeks ago

Ajax request error 422 (Unprocessable Entity)

Posted 4 weeks ago by maan56

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 sign in or create an account to participate in this conversation.