Invalid Json
Invalid Json
All of a sudden all of our Editor tables stopped working. I get the invalid JSON message. I see an ajax response with the data we need but when I run it through lint is says:
Error: Parse error on line 1:
data[{ …}, { …}, {
^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'
Any help would be appreciated.
Janet
Answers
Looks like its missing a
:
betweendata
and the array. Also, since its an object it should be inside a set of braces{}
. Should look something like this:Take a look at the example client/server data exchanges.
Kevin
Okay but why is Editor doing it and how do I fix it?
Is the Editor server code you are using provided by Datatables or your own code?
Can you provide a link to the developers so the can take a look?
Kevin
I deleted anything on the page I thought might be causing a conflict and now the console says:
<br />
<b>Deprecated</b>: define(): Declaration of case-insensitive constants is deprecated in <b>/var/www/vhosts/dev-roe-vti.org/httpdocs/editor/php/DataTables.php</b>
and then the json starts. Here is the link:
https://dev-roe-vti.org/iodashboard/schoolinfo.php
I appreciate you looking into it
Looks like the problem happens when initializing the Datatable not when using the Editor. You Datatables uses this to load the data:
```js
$('#cif').DataTable( {
//sDom: "Bfrtipl",
"sDom": '<"top"<"actions">Bfl<"clear">><"clear">rtpi<"bottom">',
ajax: {
url: "../editor/php/cif_schoolinfo_processing.php",
type: 'POST'
},
````
Is
cif_schoolinfo_processing.php
a Datatables provided script or your own? That is where the debugging will need to take place to determine why the response contains:Maybe a search of https://stackoverflow.com/ will help resolve the error
Declaration of case-insensitive constants is deprecated
. See if this SO thread helps.Kevin
It is a datatables provide script that was included in Editor that we just clone. It is super simple:
I don't see a call to
define()
in that code. Do you have a call todefine()
in yourDataTables.php
script? And does it have a third parameter set totrue
?Kevin
The call to define is in Datatables.php and I changed
define("DATATABLES", true, true);
to
define("DATATABLES", true, false);
and it fixed it.
Thank you for your help
Sounds like you might have an old version of the Editor PHP libraries? We no longer use the third parameter for
define
.Allan