Javascript代码未在Wordpress页面中运行

Javascript代码未在Wordpress页面中运行,javascript,wordpress,highcharts,custom-wordpress-pages,Javascript,Wordpress,Highcharts,Custom Wordpress Pages,编辑这里是来自控制台的错误 我想在Wordpress页面中运行一些代码,这些页面在JSFIDLE中工作。 我只是把我的代码放在编辑器里,我什么也看不到。不过,如果脚本很简单,比如:由 我不知道如何创建一个.js文件,这是一个大学设置的wordpress站点,所以我怀疑我是否能控制根目录 我不能在我的Wordpress网站上创建文件,它是由一所大学管理的,不允许我创建 <script src="https://code.jquery.com/jquery-3.1.1.min.js">&

编辑这里是来自控制台的错误

我想在Wordpress页面中运行一些代码,这些页面在JSFIDLE中工作。 我只是把我的代码放在编辑器里,我什么也看不到。不过,如果脚本很简单,比如:由

我不知道如何创建一个.js文件,这是一个大学设置的wordpress站点,所以我怀疑我是否能控制根目录

我不能在我的Wordpress网站上创建文件,它是由一所大学管理的,不允许我创建

<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

<script type="text/javascript"> 
jQuery(function() {
$.getJSON(
    'https://cdn.jsdelivr.net/gh/highcharts/highcharts@v7.0.0/samples/data/usdeur.json',
    function (data) {

        Highcharts.chart('container', {
            chart: {
                zoomType: 'x'
            },
            title: {
                text: 'USD to EUR exchange rate over time'
            },
            subtitle: {
                text: document.ontouchstart === undefined ?
                    'Click and drag in the plot area to zoom in' : 'Pinch the chart to zoom in'
            },
            xAxis: {
                type: 'datetime'
            },
            yAxis: {
                title: {
                    text: 'Exchange rate'
                }
            },
            legend: {
                enabled: false
            },
            plotOptions: {
                area: {
                    fillColor: {
                        linearGradient: {
                            x1: 0,
                            y1: 0,
                            x2: 0,
                            y2: 1
                        },
                        stops: [
                            [0, Highcharts.getOptions().colors[0]],
                            [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
                        ]
                    },
                    marker: {
                        radius: 2
                    },
                    lineWidth: 1,
                    states: {
                        hover: {
                            lineWidth: 1
                        }
                    },
                    threshold: null
                }
            },

            series: [{
                type: 'area',
                name: 'USD to EUR',
                data: data
            }]
        });
    }
);
});
</script>

Wordpress通常在noConflict模式下运行jQuery,使$undefined

试着改变

 jQuery(function() {// $ undefined here


尝试通过jQuery.getJSON更改$.getJSON。这不会使其运行。您也可以使用jQuery.noConflictl,然后使用jQuery变量而不是$来执行与jQuery相关的操作。因此jQUery将引用jQUery,$将引用wordpress可能使用的其他库@几乎总是在wordpress安装中实现的AbdulMannan我不知道问题是否存在。这没有解决问题。浏览器控制台中有错误吗?这段代码是在jQuery.js加载后运行的吗?在库本身加载之前不能使用jQuery对象我有点困惑,因为有很多错误,似乎jQuery问题很多。为什么它可以在JSFIDLE中工作,但不能在这里工作?我删除了
 jQuery(function() {// $ undefined here
jQuery(function($) { // $ is jQuery here