這裏是我的代碼,我花了幾個小時,谷歌沒有成功搜索這...如何將JSON數據格式化爲使用Google Charts正確顯示?
google.load('visualization', '1', {packages: ['corechart']});
google.setOnLoadCallback(drawVisualization);
function drawVisualization(){
var jsonData = $.ajax({
url: "FinancialData.php",
// data: "ChartRequest=" + "Employees",
dataType:"json",
async: false,
}).responseText;
window.alert(jsonData); //this always returns correctly formatted data
var data = new google.visualization.DataTable(jsonData); //this never works
var chart = new google.visualization.PieChart(document.getElementById('visualization'));
chart.draw(data, {title:"Progress Fest Financial Information, Fall 2013"});
};
代碼返回「表沒有列」
它不相關,但你不應該做'異步:錯誤'。 –