Google Visualizzation - Access a Google Sheet from PhoneGap

25 views
Skip to first unread message

brian.l...@gmail.com

unread,
Jul 18, 2016, 7:14:52 PM7/18/16
to Google Visualization API
When attempting to access a google sheet from the javascript in my PhoneGap application the callback function on the query.send never gets fired. Anybody know what I could be doing wrong? The html contains:
<script type="text/javascript" charset="utf-8" src="script/gviz-api.js"></script>
...and here is my javascript code:

function googleProcess() {
var req = 'select *';
var reqenc = encodeURIComponent(req);
//DATA_SOURCE_URL = DATA_SOURCE_URL + "/gviz/tq?tq=" + reqenc; 
var query = new google.visualization.Query(DATA_SOURCE_URL);
try {
if (DATA_SOURCE_URL.indexOf("gviz") == -1) {
window.alert("Setting URL Without Query: " + DATA_SOURCE_URL);
console.log("Setting URL Without Query: " + DATA_SOURCE_URL);
window.alert("Query: " + req);
console.log("Query: " + req);
query.setQuery(req);
} else {
window.alert("Setting URL WITH Query: " + DATA_SOURCE_URL);
console.log("Setting URL WITH Query: " + DATA_SOURCE_URL);
}
query.send(handleQueryResponse);
} catch (e) {
window.alert("Error in Query Processing: " + e.message);
}
window.alert("Query Sent OK");

function handleQueryResponse(response) {
window.alert("Handling Response");
if (response.isError()) {
        alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
        return;
      }
    var data = response.getDataTable();
    window.alert("Data is: " + data);
}
Reply all
Reply to author
Forward
0 new messages