javascript jquery 和 highcharts SCRIPT1014 的无效字符错误:无效字符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17428903/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 08:17:23  来源:igfitidea点击:

invalid character error with jquery and highcharts SCRIPT1014: Invalid character

javascriptjqueryhighcharts

提问by tuj

Trying to do a really basic highchart, but I keep getting the error: "JavaScript critical error at line 42, column 12. SCRIPT1014: Invalid character. I have included jQuery in the header so I'm not sure what I'm doing wrong. Testing with IE.

试图做一个非常基本的 highchart,但我不断收到错误:“JavaScript 严重错误在第 42 行,第 12 列。SCRIPT1014:无效字符。我在标题中包含了 jQuery,所以我不确定我做错了什么. 用IE测试。

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js">  </script>
    <script src="http://code.highcharts.com/highcharts.js"></script>
    <title></title>
</head>
<body>
    <div id="container" style="width:100%; height:400px;"></div>
    <script type="text/javascript">
        $(function () { 
            $('#container').highcharts({
                chart: {
                    type: 'bar'
                },
                title: {
                    text: 'Fruit Consumption'
                },
                xAxis: {
                    categories: ['Apples', 'Bananas', 'Oranges']
                },
                yAxis: {
                    title: {
                        text: 'Fruit eaten'
                    }
                },
                series: [{
                    name: 'Jane',
                    data: [1, 0, 4]
                }, {
                    name: 'John',
                    data: [5, 7, 3]
                }]
            });
        });?
    </script>    
</body>
</html>

回答by kmas

I got a special character '?' when I copy your code just after the last semicolon. Try to copy your code in a text editor (notepad++ for me), remove this character and copy again your page.

我有一个特殊字符“?” 当我在最后一个分号之后复制您的代码时。尝试在文本编辑器(对我而言是记事本++)中复制您的代码,删除此字符并再次复制您的页面。

It has worked for me.

它对我有用。

回答by tuj

I took out the very last ";" in the jQuery block of code and it worked. Weird...

我取出最后一个“;” 在 jQuery 代码块中,它起作用了。奇怪的...

回答by Sebastian Bochan

In the future I advice to use jslintwhich check your syntax.

将来我建议使用jslint来检查你的语法。