REMARK: USING XAMPP
On PHP I'm using json_encode() to return data to a JS/JQuery ajax request.
The ajax call from .js:
$.ajax({url: "/sys/search_rf/functions.php" ,
async: false, // wait for reponse
type: "post",
data: { id: $('#id').val(),
status: $('#status').val(),
token: cToken } ,
success: function(jsonResponse,status){ // POST success
console.log(jsonResponse);
jsonData = JSON.parse(jsonResponse);
[...]
}
It works just fine until I require_once() another .php in functions.php.
require_once(dirname(dirname(__FILE__)).'/searches.php'); // -> ../searches.php
Output debug:

None of the included PHP echoes/print anything at all, except the function which returns the json_encode().
So then, I edited searches.php and left it like this (debugging purpose):
<?php
?>
So I'm 100% sure nothing is echoing, and I kept:
require_once(dirname(dirname(__FILE__)).'/searches.php'); // -> ../searches.php
in functions.php, which responds to ajax request.
But the error stills:
SyntaxError: JSON.parse: unexpected character
And if I comment it, there will be no errors!
// require_once(dirname(dirname(__FILE__)).'/searches.php'); // -> ../searches.php
I suppose every time I require_once() it 'echoes' something. I don't really know.
I also checkd all EOL/Encoding of all files. All in Unix Format encoded in UTF-8.
This workaround will do, but I think it's not the proper solution:
jsonData = JSON.parse( jsonResponse.trim() );
.trim()
?>removing should solve the issue... There are only pair questionmarks(cr/lf?) in responseob_start();/ob_end_clean();and removing the?>. It ONLY WORKS if I do notrequire_once(dirname(dirname(__FILE__)).'/searches.php');even though it has nothing on it.