未捕获的SyntaxError:输入JavaScript的意外结束

时间:2015-02-13 01:47:44

标签: javascript

我是js的新手并且不断收到错误“Uncaught SyntaxError:意外的输入结束”并且无法弄清楚错误是什么给我的生命。有没有人看到我可能会忽略的任何明显的东西?谢谢

 <html>
    <head>
        <script type="text/javascript" src="https://www.google.com/jsapi"></script>
        <script type="text/javascript">
        google.load("visualization", "1", {packages:["motionchart"]});
        google.setOnLoadCallback(drawChart);
        function drawChart() {
            var data = new google.visualization.DataTable();
            data.addColumn('string', 'Type of App');
            data.addColumn('date', 'Date');
            data.addColumn('number', 'Sales');
            data.addRows([
              ['Apps',  new Date (2009,0,1), 2380],
              ['Games',  new Date (2009,0,1), 571],
              ['Games', new Date (2009,0,6), 978],
              ['Apps',  new Date (2009,0,12), 14069],
              ['Games',  new Date (2009,0,12), 2307],
              ['Apps', new Date (2010,0,1), 11465],
              ['Games', new Date (2010,0,1), 1520],
              ['Apps',  new Date (2010,0,6), 13490],
              ['Games',  new Date (2010,0,6), 2126],
              ['Apps', new Date (2010,0,12), 20285],
              ['Games', new Date (2010,0,12), 4025],
              ['Games',  new Date (2011,0,1), 2820],
              ['Apps', new Date (2011,0,6), 12757],
              ['Apps',  new Date (2011,0,12), 16785],
              ['Apps', new Date (2012,0,1), 16097],
              ['Apps',  new Date (2012,0,6),17449],
              ['Games',  new Date (2012,0,6), 3694],
              ['Apps', new Date (2012,0,12), 21691],
              ['Games', new Date (2012,0,12), 5774],
              ['Games',  new Date (2013,0,1), 4903],
              ['Apps', new Date (2013,0,6), 23295],
              ['Games', new Date (2013,0,6), 5323],
              ['Apps',  new Date (2013,0,12), 27733],
              ['Games',  new Date (2013,0,12), 9105],
              ['Apps', new Date (2014,0,1), 30771],
              ['Games', new Date (2014,0,1), 7289],
              ['Apps',  new Date (2014,0,6), 32992],
              ['Games',  new Date (2014,0,6), 11752],
              ['Apps', new Date (2014,0,12), 30816],
              ['Apps',  new Date (2015,0,1), 29866],
              ['Games',  new Date (2015,0,1), 10183]
              ]);

    var chart = new google.visualization.MotionChart(document.getElementById('chart_div'));

    chart.draw(data, {width: 600, height:300});
    </script>
    </head>
    <body>
        <div id="chart_div" style="width: 600px; height: 300px;"></div>
    </body>
    </html>

2 个答案:

答案 0 :(得分:2)

你错过了关闭&#34;}&#34; function drawChart() {

答案 1 :(得分:2)

JS Lint是你的朋友。你在drawChart函数的末尾缺少一个结束'}'(第45行)。