admin管理员组

文章数量:1423931

I am getting this error message when trying to create a table using the Google Visualization API, with PHP & MySQL in the background.

  • db connection is OK
  • creating JSON from PHP array is OK
  • JSON format is OK

This is the error I get: uncaught referenceerror: table is not defined

 <!--Load the AJAX API-->
<script type="text/javascript" src=""></script>
<script type="text/javascript">

 // Load the Visualization API and the table package.
  google.load('visualization', '1.0', {'packages':['table']});
  google.setOnLoadCallback(drawTable);

  function drawTable() {
        var tdata = new google.visualization.DataTable(
        <?php echo json_encode($data); ?>);
    var options = {
      title: 'A Station'
    };
    var table_draw = new google.visualization.Table(document.getElementById('table_div'));
    table_draw.draw(tdata, options);
  }

I am getting this error message when trying to create a table using the Google Visualization API, with PHP & MySQL in the background.

  • db connection is OK
  • creating JSON from PHP array is OK
  • JSON format is OK

This is the error I get: uncaught referenceerror: table is not defined

 <!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google./jsapi"></script>
<script type="text/javascript">

 // Load the Visualization API and the table package.
  google.load('visualization', '1.0', {'packages':['table']});
  google.setOnLoadCallback(drawTable);

  function drawTable() {
        var tdata = new google.visualization.DataTable(
        <?php echo json_encode($data); ?>);
    var options = {
      title: 'A Station'
    };
    var table_draw = new google.visualization.Table(document.getElementById('table_div'));
    table_draw.draw(tdata, options);
  }
Share Improve this question edited Oct 24, 2014 at 20:38 nazanin asked Oct 24, 2014 at 19:42 nazaninnazanin 733 silver badges14 bronze badges 1
  • what this has anything to do with php and mysql? – itachi Commented Oct 24, 2014 at 20:07
Add a ment  | 

1 Answer 1

Reset to default 4

You are trying to use a variable, table, which you have never defined.

Possibly you wanted to use the variable table_draw which you have defined in the line before.

var table_draw = new google.visualization.Table(document.getElementById('table_div'));
table_draw.draw(tdata, options);

本文标签: javascriptuncaught referenceerror table is not definedStack Overflow