My working code is below, but it chokes when I add more than 5 queries. Can anyone offer some guidance?

 var dataA = "";
      var dataB = "";

        function initialize() {
              var opts = {sendMethod: 'auto'};
              var queryString = encodeURIComponent('SELECT J, K, C, E, F WHERE I=1');

              var queryA = new google.visualization.Query(
                  'https://docs.google.com/spreadsheets/d/xxx=' + queryString);

              var queryB = new google.visualization.Query(
                  'https://docs.google.com/spreadsheets/d/xxx=' + queryString);

            queryA.send(handleQueryResponse);

            queryA.send(getDataA);
            queryB.send(getDataB);

        }

        function handleQueryResponse(response) {
              if (response.isError()) {
                alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
                return;
              }
        }

        function getDataA(response){ 
            dataA = response; 
            drawThatChart();                       

        }

        function getDataB(response){
              dataB = response;
              drawThatChart();
        }

        function drawThatChart(){


            drawChart(dataA, dataB);

        }


function drawChart(a, b) {

Recommended Answers

All 3 Replies

Thank you, rproffitt, but even with 4 queries, the page is sometimes blank and I have to refresh to see the chart populate. I believe the problem lies in the code below, which doesn't always receieve the data before trying to draw the table. Is there a better way to combine these queries so all the data is passed once to this function?

function drawChart(a, b) {

Queries may take time. Maybe after line 35 you can do some data dump to see what came back?

Full disclosure. Not an area I've used but have run into Google API limits and speed bumps over the years.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.