Serverside processing response void in production
Serverside processing response void in production
Link to test case: https://www.lasinistrapermonfalcone.it/pagamenti_comune/
Debugger code (debug.datatables.net): epoves
Error messages shown: DataTables warning: table id=example - Invalid JSON response. For more information about this error, please see https://datatables.net/tn/1
Description of problem: running on MAMP environment with the same DB data all works fine. When in production (see url above) the search with some terms gives the invalid JSON response error and the response is void in network tab of inspector.
This happens searching in the right upper field terms like "marit" but "mari" works.
Another problematic term is "cuz" with the same error type.
I think there are a loto of terms that generate the error.
I repeat: the same situation but under MAMP works fine.
thansk a lot
Replies
to see the datatable:
user: lega
pswd: merda
Are you using a Datatables supplied server side processing script?
The server script will need debugging to determine why there is an empty response. Should searching for
marit
return rows or does it result in no rows to be returned?Kevin
no response, no rows, the loader running and the popup for datatatbles help
The page gets this error:
when searching for
marit
. As you mentioned the response is blank. Maybe start with answering my above questions.Kevin
Just to add to Kevin's reply, empty data is not valid JSON (hence the error). So if your script isn't returning anything, then the error is perfectly correct. As Kevin says, please answer his questions so we can offer some help.
I'd suggest you check the server's error logs as well.
If there are no matching rows, then the server still needs to respond with valid JSON, per the communication protocol - you just need to have
data
as an empty array.Allan
Yes Allan, I know that the problem is an invalid formatted JSON but if the inspector got at least some rows of the response I can find the problem and fix it but an empty response doesn't help me. It's strange that the same DB with the same data set in local environment has no errors. So I think that is something happened at the importing step in PHPMyAdmin (I exported data with Querious in SQL format and then imported in PHPMyAdmin).
thanks
It does, because it tells you the error is in the server-side script you are using and isn't a client-side issue. Did you check the server's error logs like I suggested? Its a PHP server, so you'll have an error log somewhere, depending on how it is configured.
Allan
You can check yourself if there is a suggestion in browser inspector or a fragment of the broken JSON. Maybe I'm searching for it in a wrong place but I didn't find it.
I didn'find the error in server log. I can try to write errors in a file in the root. This server hosting is veery simple and has few or none customizations.
Thanks for an help
I don't know what http server you are using, or how it is configured, so I can't say where the logs would be. Usually
/var/log/
or~/logs
would be the place to look, but it really depends on how it is configured.What I can suggest is that you add:
At the top of your PHP script. It should force it to display errors so you can debug it.
Allan
I just configured PHP in order to output errors but I have a blank page. Either the server error log has a three days ago update date.
So I add there row of code before the SSP JSON encoding:
print_r( SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns ));
exit;
and I saw the dump in attach with ? chars.
In PHPMyAdmin I substituted those chars with ' and the term "cuz" now doesn't make any error.
So I understood that the problem concerned chars encoding.
I added the JSON_INVALID_UTF8_IGNORE parameter in JSON_ENCODE function and now all seems running correctly.
Probably importing the data in PHPMyAdmin some UTF-8 char has not been converted or saved correctly blocking the JSON encode function.
Probably your PHP / MySQL connection needs to be set with
SET NAMES utf8
.Good to hear you've got a solution.
Allan