Issue
I'm using this library : https://github.com/simon-begin/cakephp-datatables with composer in a Cakephp 3 project. When i call drawTable function , i have this error :
Uncaught SyntaxError: Unexpected end of input
On the loaded file (cakephp.dataTables.js) on the browser, I can see that a new blank line is added at the beginning of the file, and the last character is removed.
I don't have this error if :
- I added a new blank line at the end of the javaScript file (on vendor/simon-begin/cakephp-datatables/cakephp.dataTables.js , It's only for testing pursose)
I copied the js file in an other folder and include it like so :
<?= $this->Html->script( [ 'datatables/jquery.dataTables.min', 'datatables/dataTables.bootstrap.min', 'newfolder/cakephp.dataTables', ], ['block' => 'scriptBottom'] ); ?>
instead of :
<?= $this->Html->script( [ 'datatables/jquery.dataTables.min', 'datatables/dataTables.bootstrap.min', 'DataTables.cakephp.dataTables', ], ['block' => 'scriptBottom'] ); ?>
You can see this error on : https://maisonlogiciellibre.org/organizations
So I want to know what is causing this error, and how to fix it properly .
Solution
You likely have a whitespace somewhere at the beginning of one the involved .php
files.
Unlike regular application assets, which are handled directly by the server without ever hitting PHP, plugin assets are by default being served through CakePHP, hence such mistakes will affect the output, as the Content-Length
header is being set based on the assets filesize, causing the extra byte(s) for the whitespace being truncated from the end of the response body.
Answered By - ndm
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.