Alen Alen - 3 months ago 11x
JSON Question

Uncaught SyntaxError: Unexpected token < On Chrome

I know this question has been asked many times but I can't find similarity with my issue. I'm getting this error only in Chrome, in every other browser everything is ok. I return data with JSON in several places but since my code works in other browsers I assume nothing is wrong with it.
Chrome doesn't show me where is error (in my code) it shows me these errors:

enter image description here

This is how I use JSON:

$.post("getData.php", {'id' : id}, function(data){
var obj = jQuery.parseJSON(data);

... some mysqli query
$data = $query->fetch_assoc();
echo json_encode($data);

So I don't see a problem here, can someone help me with this.


Error with Uncaught SyntaxError: Unexpected token < using @Mario answer but that was only part of my problem. Another problem is, javascript doesn't get any data from PHP file. That was solved using this code, inside PHP file: header("Content-Type: text/javascript; charset=utf-8"); This answer is found on this link, where I opened another question to solve this issue: Can't receive json data from PHP in Chrome and Opera