I\'m successfully saving my data into a json file with a php script (save-data.php) but I\'m unable to fetch it correctly with my get-data.php script.
Er
Invariably, 99.9999999% of the time you get Unexpected token < in JSON as position 0
in the error, you did NOT receive json from the server. You received an HTML error message with your json following afterwards.
<p>PHP warning: blah blah blah</p>
{"foo":"bar"}
The leading <
in the <p>...
is where the error comes from, because that's position 0 (first character).
Check the raw data coming back from the server, and fix whatever the error/warning that PHP is spitting out.
Please Check your PHP file. In that might be unwanted echo is present so the json response could not get the exact response. I resolve my issue in this way. Hope this is helpful!!