Closed ranferi closed 7 years ago
Forget it. The answer is in here:
DataTables performs JSON requests and CakePHP's JSON view uses the _serialize view variable to determine which view variables to send back. The DataTables plugin sets a bunch of these, so it is crucial to append the data variable here. If your view variable is not called 'data', set DataTables ajax.dataSrc option.
When I changed the name of $data, for example, $users and tried to load the next items from the table the browser's console throw me this errors TypeError: c is undefined (datatables.min.js) and TypeError: data is undefined (datatables.js debug). Changed back my code and it works. So should I left that variable as it is? Or there's a problem with my code? My code: `$users = $this->DataTables->find('Users', 'all', [ 'contain' => [], 'order' => ['id' => 'asc'] ]);
$this->set('users', $users); $this->set('_serialize', array_merge($this->viewVars['_serialize'], ['users']));`
and