How can I use the modified value of my global variable numRes
outside of the function that modifies its value?
When I access it after modification, I get only the initial value.
The How do I change the value of a global variable inside of a function and How do I return the response from an asynchronous call? questions describe something similar, but they did not help.
Thank you in advance for your kind help.
google.load('visualization', '1');
// ...
var query = new google.visualization.Query(
'http://www.google.com/fusiontables/gvizdata?tq=' + queryText);
numRes = 0;
query.send(function(response) {
numRes = response.getDataTable().getNumberOfRows();
console.log(numRes + " results are found - inside query.send"); // correct
});
// how to get the same value as three lines above?
console.log(numRes + " results are found"); // not correct, gives 0
// setTimeout(console.log(numRes + " results are found - after timeout"), 10000); // does not help
foo = numRes;
// ... code with foo