EDITOR DATATABLE AJAX POST IS EMPTY ARRAY ON CI4
EDITOR DATATABLE AJAX POST IS EMPTY ARRAY ON CI4
Hello,
I need to experiment Editor Datatable on CI4, first attempt everything was working and then all crached. I spend two days trying to found the issue but always failed. if someone can help fix it.
Credentials :
https://comebillets.com/agenceamani.com/login
Login : admin@example.com
Pass: admin
Editor link : https://comebillets.com/agenceamani.com/loyers
DataTables warning: table id=loyersTable - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1:
Status code 200 OK but $_POST variable is empty on the CI4 controller
Replies
This i your Datatables
ajax
config:Are you expecting POST parameters to be sent? If so then use
ajax.data
.This is the JSON response:
I'm not familiar with Codeigniter but maybe this SO thread will give you some ideas of how to return the JSON response. Debugging why the array is empty would require debugging the server script. There is nothing we can look at on the client side to help with this issue.
Kevin
Hello Kevin,
My Controller is function :
$_POST variable is empty, is not supposed to post the table columns ? to model? im confused.
//Model
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
Noted that same code is working on CI3
Only when
serverSide
is enabled will the server side processing parameters be sent to the server. Are the server side processing parameters what you are expecting to be sent?Kevin
Js code look like :
Edited by Allan to add syntax highlighting
With that initialisation, a POST request, with no data parameters will be sent to
ViewLoyers
when the DataTable is initialised.For create, edit and delete actions, Editor will POST data in the format shown here to the same route.
At the moment
ViewLoywers
is returning:which looks like a PHP
print_r()
statement. That isn't valid JSON, hence the error.What I would suggest doing is adding some logging to make sure that you are getting into the
getLoyers
method, and where in it you are getting to.Allan
Hello Allan,
Thank you, the issue was here : DB code was deleted by error.
$this->loyersModel->init($db);
public function loyers($post)
{
// DataTables PHP library
require_once APPPATH . 'Libraries/EditorLib/DataTables.php';
$this->loyersModel->init($db);
return $this->loyersModel->getLoyers($post);
}
No worries - good to hear you got it working.
Allan