David Harden
unread,Apr 10, 2012, 4:49:30 AM4/10/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to google-visua...@googlegroups.com
Hello,
I have copied the three files from google's example "Populating Data Using Server-Side Code" under "Connecting Your DataBase" (i.e., exampleUsingPHP.html, getData.php and sampleData.json) to my server but I'm having trouble getting the chart to display.
It displays OK if I run getData.php from my browser's address bar (Firefox 11.0 and MacBook) and then copy and paste the json it echos from the screen directly into exampleUsingPHP.html as shown below:
var jsonData = { "cols": [ {"id":"","label":"Topping","pattern":"","type":"string"}, {"id":"","label":"Slices","pattern":"","type":"number"} ], "rows": [ {"c":[{"v":"Mushrooms","f":null},{"v":3,"f":null}]}, {"c":[{"v":"Onions","f":null},{"v":1,"f":null}]}, {"c":[{"v":"Olives","f":null},{"v":1,"f":null}]}, {"c":[{"v":"Zucchini","f":null},{"v":1,"f":null}]}, {"c":[{"v":"Pepperoni","f":null},{"v":2,"f":null}]} ] };
BTW, Google DO NOT show a semi colon after the last curly bracket in their json example file (sampleData.json) and the chart won't display without it.
So, I think my problem lies with the following ajax function:
var jsonData = $.ajax({
url: "getData.php",
dataType:"json",
async: false
}).responseText;
I have read through the JQUERY documentation for jQuery.ajax() but can't find anything wrong. Also, I thought maybe ajax didn't like spaces in its json but manually deleting them from sampleData.json didn't help.
Now, I have run out of ideas and would greatly appreciate any help.
David Harden