I'm following this example from amCharts but I can't load JSON from PHP file, this what have I done:
AmCharts.loadJSON = function(url) {
if (window.XMLHttpRequest) {
var request = new XMLHttpRequest();
} else {
var request = new ActiveXObject('Microsoft.XMLHTTP');
}
request.open('GET', url, false);
request.send();
return eval(request.responseText);
};
AmCharts.ready(function() {
var chartData = AmCharts.loadJSON('chart.php');
console.debug(chartData);
});
But I always get:
return eval(request.responseText);
Uncaught SyntaxError: Unexpected string
I have googled but all solutions include jQuery, and it's recommended not to use eval.
evalis for evaluate a string as a script, its not for ajson object.JSON.parse()to parse JSON - noteval()...