Reputation: 2591
I am trying to use google charts on my page to display stuff from google analytics.
I have split my analytics reports into more sections: Pages, Browsers, Operating Systems, Traffic sources etc...
I have a handler which gets my request and performs an ajax call to one of my files. For example: if i request Pages, my handler shows the ajax loading graphic and sends a request to ajax_pages.php. When finished it appends the html in a div.
Here's the problem: putting google charts code in any of the ajax_*.php files will not load the js...AT ALL! Any other javascript code will load. Have tried <script>alert('aaaa');</script>
and worked fine. The things is that the js code does not even appear when i View Source of the page. How could this be? At least to source code should be there no matter if it has errors.
Putting the code before the handler sends the request will display the charts.
Upvotes: 2
Views: 2762
Reputation: 3941
google.load tries to write to an already finished document. My solution was to amend my loading script with a callback:
google.load("visualization", "1", {"packages": ["corechart"], "callback": drawFlyAtlasChart});
Upvotes: 5