i just switched to a mac today and i noticed the JSON.parse that works on other browsers, throws this error on safari.
Unhandled Promise Rejection: SyntaxError: JSON Parse error: Unexpected identifier "undefined"
This is the JSON response from my PHP code
{"dataPointsX": "[\"31 Jan\",\"01 Feb\",\"02 Feb\",\"03 Feb\",\"04 Feb\",\"05 Feb\",\"06 Feb\"]", "dataPointsY": "[\"0\",\"0\",\"7287\",\"24572\",\"30657\",\"27865\",\"0\"]", "dataPoints2Y": "[\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]"}
This is my Javascript code
$.get('chartdata.php', async function (res) {
console.log(res)
var res = JSON.parse(res);
});
Please help
UPDATE
I have updated my PHP to echo this
{"dataPointsX":["31 Jan","01 Feb","02 Feb","03 Feb","04 Feb","05 Feb","06 Feb"],"dataPointsY":["0","0","7287","24572","30632","27820","0"],"dataPoints2Y":["0","0","0","0","0","0","0"]}
It works on chrome, safari still throwing this error
Unhandled Promise Rejection: SyntaxError: JSON Parse error: Unexpected identifier "undefined"
Console.log(JSON.parse(res)) shows this on chrome
dataPoints2Y: (7) ['0', '0', '0', '0', '0', '0', '0']
dataPointsX: (7) ['31 Jan', '01 Feb', '02 Feb', '03 Feb', '04 Feb', '05 Feb', '06 Feb']
dataPointsY: (7) ['0', '0', '7287', '24572', '30489', '27744', '0']
[[Prototype]]: Object