CSRF was invalid, DELETE method

Hello to everybody,
I have a table page where I want to edit and delete my objects. Edit is working whitout any problem.
I have a problem with delete method.

The button is inside a list and this is the code:

      <a onclick="return deleteSchema('{{row.id}}')" class="btn-trash">
           <i class="fas fa-trash-alt"></i> {% endverbatim %}{{translate("DELETE")}}{% verbatim %}

And this is deleteSchema function used to call my delete method but everytime I have error CSRF code was invalid

<script  type="text/javascript">

        function deleteSchema(arg1){

                type: "DELETE",
                url: "{{site.uri.public}}/formgenerator/"+arg1,
                success: function (response) {

                error: function (xhr, status, error) {
                    var err = eval("(" + xhr.responseText + ")");


Can anyone help me ?

You need to pass csrf_name and csrf_value in your payload : https://learn.userfrosting.com/routes-and-controllers/client-input/csrf-guard#injecting-the-tokens-into-ajax-requests

1 Like

Thanks I tried it also last time but probably I was putting that values in a wrong place. Now it is working