虽然我在检查器中看到数据,但无法使用PHP / Ajax / jSON填充select2

I developed a web application on Windows (XAMPP environment). Everything was working, but when I published it on a Linux Server I got a strange issue which is driving me mad. I've read all possible posts on SO, still i can't get the solution.

The problem is that all the select2 fields are not being updated by Ajax.

I am using select2 (ver. 3.x) populating it with jSON on searching. With PHP I return a jSON formatted set of data

header('Content-type: application/json');
...    
echo json_encode(array(
                'results' => $prepared_data,
                'more' => (@db_num_rows($res) >= $results_per_page),
                'elapsed' => round(microtime(true) - $start_ts, 3)
            ));

which is giving me a set of data in Chrome Inspector (Network -> Response) like:

{"results":[{"id":"8","text":"-- Scegli il Distretto --"},{"id":"3","text":"Distretto Centro"},{"id":"2","text":"Distretto Nord Est"},{"id":"1","text":"Distretto Nord Ovest"},{"id":"6","text":"Distretto Sardegna"},{"id":"7","text":"Distretto Sicilia"},{"id":"4","text":"Distretto Sud Est"},{"id":"5","text":"Distretto Sud Ovest"}],"more":false,"elapsed":0.109}

The only strange thing I notice is that before that string I can see a small dot in the Chrome network console response. Hovering it with the mouse I read it is \ufeff. There is no error in the console of Chrome, neither a network one.

Could anybody point me to the right direction in order to debug and possibly solve this issue?

I answer my own question...

The problem was a BOM mark at the beginning of a config.php file.

What I did, on a Mac, was...

1) With terminal cd into the app directory and:

grep -rl $'\xEF\xBB\xBF'

In this way I listed the files which had EF BB BF sequence at their beginning

2) Downloaded a HEX editor such as HEX FIEND and removed the sequence in the files of the list (in my case just one).

That's it. All was working after that!

Fabio