I am getting a CORB error with the following script, and I cant seem to figure out why.
<script>
var chart = null;
var dataPoints = [];
window.onload = function() {
chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
theme: "light2",
title: {
text: "Daily Sales Data"
},
axisY: {
title: "Sold For",
titleFontSize: 24
},
data: [{
type: "line",
yValueFormatString: "$#,##0.00",
dataPoints: dataPoints
}]
});
$.getJSON("https://www.hostname.com/test/examples/01-overview/test.php?callback=?", callback);
}
function callback(data) {
console.log(data.dps);
for (var i = 0; i < data.dps.length; i++) {
dataPoints.push({
x: new Date(data.dps[i].date),
y: data.dps[i].units
});
}
chart.render();
}
</script>
I noticed that the format from the example is
callback({
"dps":[
{
"date":"08/18/2020",
"units":1550.00
} //more here
]
})
my PHP file returns this..
{"callback":[
{"dps":[
{
"date":"08\/18\/2020",
"units":"1550.00"
}, {...}
]}
]}
Im not sure if thats why...