0
我嘗試從MySQL中獲取php數據,將json編碼爲javascript文件以繪製折線圖。json數據未解析爲
我的JSON數據看起來像
PHP data.php
[
{"x":"1","y":"925"},{"x":"2","y":"1000"},{"x":"3","y":"1000"},{"x":"4","y":"11"},{"x":"5","y":"52"},{"x":"6","y":"84"},{"x":"7","y":"109"},{"x":"8","y":"132"},{"x":"9","y":"270"},{"x":"10","y":"291"},{"x":"11","y":"306"},{"x":"12","y":"330"},{"x":"13","y":"356"},{"x":"14","y":"374"},{"x":"15","y":"395"},{"x":"16","y":"411"},
...
{"x":"33","y":"887"},{"x":"34","y":"905"},{"x":"35","y":"921"},{"x":"36","y":"940"},{"x":"37","y":"1000"},{"x":"38","y":"1000"}
]
當嘗試解析這個數據到我的js html和在瀏覽器中它沒有打開網頁任何內容:
<script src="jquery.js"></script>
<script src="canvas/canvasjs.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.getJSON("data.php", function (result) {
var chart = new CanvasJS.Chart("chartContainer",
title:{
text: "Documents"
}
{
data: [{dataPoints: result}]
});
chart.render();
});
});
</script>
</head>
有沒有人看到這裏有什麼可能是錯的?或者可以給一些提示如何解決這個問題? 我在看chrome的開發者工具,但是並沒有顯示任何錯誤。 感謝
由於年底缺逗號對於答案,我刪除了整個文本:...塊,但仍保持瀏覽器爲空。你有什麼其他的建議? – user3297709