Я получил 403 Forbidden Error при попытке реализовать jQuery-Tabledit (https://markcell.github.io/jquery-tabledit/) на моей таблице. При исследовании кажется, что проблема связана с авторизацией, однако я понятия не имею, как исправить. Я не использую ниAuthComponent или SecurityComponent.
Шаблон / Пользователь / index.ctp
<div class="user index large-9 medium-8 columns content">
<h3><?= __('User') ?></h3>
<table id="table" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th scope="col">Id</th>
<th scope="col">Name</th>
<th scope="col">Email</th>
</tr>
</thead>
<tbody>
<?php foreach ($user as $user): ?>
<tr>
<td><?= $this->Number->format($user->id) ?></td>
<td><?= h($user->name) ?></td>
<td><?= h($user->email) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?= $this->Html->script('/js/table_edit_test') ?>
webroot / js / table_edit_test.js
$(document).ready(function(){
$('#table').Tabledit({
url:"/user/testing",
columns: {
identifier: [0, 'id'],
editable: [[1, 'name'],
[2, 'email']]
},
onSuccess: function(data, textStatus, jqXHR) {
console.log('onSuccess(data, textStatus, jqXHR)');
console.log(data);
console.log(textStatus);
console.log(jqXHR);
},
onFail: function(jqXHR, textStatus, errorThrown) {
console.log('onFail(jqXHR, textStatus, errorThrown)');
console.log(jqXHR);
console.log(textStatus);
console.log(errorThrown);
},
onAjax: function(action, serialize) {
console.log('onAjax(action, serialize)');
console.log(action);
console.log(serialize);
},
});
});
UserController.php
public function index() {
$user = $this->paginate($this->User);
$this->set(compact('user'));
}
public function testing() {
$this->autoRender = false;
if($this->request->is('Ajax')) {
$input = filter_input_array(INPUT_POST);
if($input["action"] === 'edit') {
$user = $this->User->get($input["id"]);
$user->name = $input["name"];
$user->email = $input["email"];
$this->User->save($user);
}
return json_encode($input);
}
}
AppController.php
public function initialize() {
parent::initialize();
$this->loadComponent('RequestHandler', [
'enableBeforeRedirect' => false,
]);
$this->loadComponent('Flash');
/*
* Enable the following component for recommended CakePHP security settings.
* see https://book.cakephp.org/3.0/en/controllers/components/security.html
*/
//$this->loadComponent('Security');
}
Снимок экрана отладки:
Буду признателен за любую помощь.