I'm trying to draw table through Google visualization API based on mysql database
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="jquery-1.11.1.min.js"></script>
<script type="text/javascript">
google.load('visualization', '1.0', {'packages':['table']});
google.setOnLoadCallback(drawItems);
function drawItems(num) {
//alert(num.value);
var jsonTableData = $.ajax({
url: "gettabledata.php",
data: "q="+num,
dataType:"json",
async: false
}).responseText;
The client side javascript code that receives the json:
var tabledata = new google.visualization.DataTable(jsonTableData);
var table = new google.visualization.Table(document.getElementById('table_div'));
table.draw(tabledata);
}
This causes the following error on constructing the DataTable object (first line):
Uncaught Error: Invalid JSON string
This is the json (generated by the google api):
{"cols":[{"id":"Name","label":"Arr Name","type":"string"},{"id":"PMU","label":"PMU","type":"string"}],"rows":[{"c":[{"v":"a_b_c_Yellow"},{"v":"b"}]}]}