The responseText property of the AJAX call gives the string value of the returned data, which is not usable by the arrayToDataTable method. Assuming jsonData is a valid JSON string for a javascript array, you need to call JSON.parse on jsonData:
var data = new google.visualization.arrayToDataTable(JSON.parse(jsonData)); On Thursday, February 20, 2014 4:41:35 PM UTC-5, mkin...@gmail.com wrote: > > Im trying to get the basic PHP example to work. > > > This is what I want to work, but does not: > > function drawChart() { > var jsonData = $.ajax({ > url: "getData.php", > dataType:"json", > async: false > }).responseText; > > // Create our data table out of JSON data loaded from server. > var data = new google.visualization.arrayToDataTable(jsonData); > > my getData.php does some sql and parsing. If I do this instead, it works > fine, just only once since its php instead of a jquery ajax call : > > function drawChart() { > > // Create our data table out of JSON data loaded from server. > var data = new google.visualization.arrayToDataTable( <?php include > 'getData.php'; ?> ) > > If I do > > var jsonData = $.ajax({ > url: "getData.php", > dataType:"json", > async: false > }).responseText; > > document.write(jsonData); > > > // Create our data table out of JSON data loaded from server. > var data = new google.visualization.arrayToDataTable( PASTE STUFF HERE > ); > > and then run it once to cut and paste the output into PASTE STUFF HERE > then it works fine. If I actually use the jsonData variable as in the > example, it does not work. What newb mistake am I making here? > > > > -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsubscr...@googlegroups.com. To post to this group, send email to google-visualization-api@googlegroups.com. Visit this group at http://groups.google.com/group/google-visualization-api. For more options, visit https://groups.google.com/groups/opt_out.