title: How to pass an array from PHP to javascript using JSON to make a Google Chart?
body: <p>I want to make a Google Chart and I am trying to send a JSON encoded array from a PHP script to a JavaScript. The two files are as follows:</p>
  
  <pre><code>&lt;html&gt;
  
  &lt;head&gt;&lt;title&gt;
  
  &lt;/title&gt;&lt;/head&gt;
  
  &lt;body&gt;
  &lt;?php
  $data[0]=array('State','Values');
  $data[1]=array('Correct',6);
  $data[2]=array('Incorrect',3);
  
  echo json_encode($data);
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is saved as test.php</p>
  
  <p>The javascript file is:</p>
  
  <pre><code> &lt;html&gt;
     &lt;head&gt;
       &lt;script type="text/javascript" src="jquery-1.9.1.min.js"&gt;&lt;/script&gt;
       &lt;script type="text/javascript" src="https://www.google.com/jsapi"&gt;&lt;/script&gt;
       &lt;script type="text/javascript"&gt;
         google.load("visualization", "1", {packages:["corechart"]});
         google.setOnLoadCallback(drawChart);
  
         function drawChart() {
  
  
      var jsonData = $.ajax({
              url: "test.php",
              dataType: "json",
              async: false
          }).responseText;
  
      var data=google.visualization.arrayToDataTable(jsonData);
  
      var options = {
        title: 'My Chart'
      };
  
      var chart = new oogle.visualization.PieChart(document.getElementById('chart_div'));
      chart.draw(data, options);
    }
       &lt;/script&gt;
     &lt;/head&gt;
  
     &lt;body&gt;
       &lt;div id="chart_div" style="width: 900px; height: 500px;"&gt;&lt;/div&gt;
     &lt;/body&gt;
  
   &lt;/html&gt;
  </code></pre>
  
  <p>This is saved as test2.php. </p>
  
  <p>When I run test2.php, nothing happens and the browser shows a blank screen. Where am I going wrong here? Please help.</p>
  
  <p>Thanks.</p>