Skip to content
Advertisement

ERROR: POST http://localhost:8765/users/delete/delete8 403 (Forbidden)

I’m using cakephp4. trying to add some sweetalert. Sweetalert is popping up when the delete button is clicked but when I click confirm for delete it’s not deleting the data.

template/layout/Users/index.php

JavaScript

template/layout/Users/index.php

JavaScript

delete method is as follows in my UsersController.php

UsersController.php

JavaScript

Route File is here config/route.php

JavaScript

});

Advertisement

Answer

I am sure it’s the CSRF token. Try to replace

JavaScript

with

JavaScript

Also I am not sure about your “beforeSend: function(xhr)”, you can see a working ajax call example here:

https://stackoverflow.com/a/67253585/15256337

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement