Kassy Coan Kassy Coan - 1 month ago 5
Javascript Question

Accessing data from Google App Engine datastore in a javascript file

What are the options for accessing information from Google App Engine datastore in a javascript file?


I am running an app on Google App Engine which uses the Google Chart Tools API. All the data which I would like to graph is in my Google App Engine datastore.


I can access the data within my python script. Also, in the python script, I encode the data to JSON. My idea was to save this in a js file, which I could import into the HTML, then build the chart there. However, this does not work, because writing to local files is not supported in App Engine.



From the python file: Write the JSON data to a URL. In App Engine, this is done with


From the Javascript, make the XHR request like this:

function getData() {
    var dataObject = new XMLHttpRequest();
    dataObject.open('GET', 'URL', true);
    return dataObject;

This will return a XMLHttpRequest object with the data in a string in the response or responseText attribute.