Sorry for the newbie question, but I've been banging my head against this 
for quite a while. 

In the dummy code below, there are three functions - two that are 
"required" by the Visualization API and one RunMe() that kicks it off. If a 
spreadsheet request is invalid, I can access the error message it returns 
from the handleQueryResponse() function. But for my purposes, I need to be 
able to test for the existence of response.isError() from within the 
runMe() function. This seems simple, but I can't seem to get at that 
response object from outside of handleQueryResponse(). This may be due to 
my JavaScript newbie status or because the API does something weird.

I also find it weird that uncommenting console.log(query); in the 
getTableMeta() function produces an "Er" object that just seems to be a 
prototype, not a representation of the actual query.

Thanks for suggestions.

The spreadsheet ID below is invalid with the "z" at the end and valid with 
it removed.

function runMe() {
    var foo = getTableMeta('0AtP_YtDJ532RdDcxZUl6Zkl4YkxKcEYzbld4ZDA4SlEz');
    // console.log(response);
    // console.log(response.getMessage());
    // console.log(foo.getMessage());
}  


// Get table metadata from Google
function getTableMeta(spreadsheet_id) {

    var query = new 
google.visualization.Query('https://spreadsheets.google.com/a/google.com/tq?key='
 
+ spreadsheet_id);
    // console.log(query);
    query.send(handleQueryResponse); 
    }       


function handleQueryResponse(response) {
    if (response.isError()) {
        // alert('Error in query: ' + response.getMessage() + ' ' + 
response.getDetailedMessage() + '. Please click Previous and enter a 
different spreadsheet ID.');
        console.log(response.getMessage());
    }    
    return response;
}   

runMe();

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-visualization-api/-/7N-JHH_2J0oJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to