未捕获的Highcharts错误#16:www.highcharts.com/errors/16 [英] Uncaught Highcharts error #16: www.highcharts.com/errors/16

查看:89
本文介绍了未捕获的Highcharts错误#16:www.highcharts.com/errors/16的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中使用highcharts.js库,我收到了Uncaught Highcharts错误#16错误:www.highcharts.com/errors/16.

I am using highcharts.js lib in my project,I am getting the error as Uncaught Highcharts error #16: www.highcharts.com/errors/16.

我知道该错误是由于lib加载两次而引起的,但是我需要如何避免这种情况的帮助.

I know that the error comes due to lib is loaded twice,but I need help that how I avoid this situation.

基本上,我正在使用ajax请求从.jsp文件获取html响应.

Basically I am using ajax request for getting the html response from .jsp file.

场景: 1.我有d3.js的树,当时我单击树节点,然后发送ajax请求并获取整个html响应页面,因为其中包括highchars.js lib

Scenario: 1.I have tree from d3.js where I am clicking on the tree node at that time I am sending the ajax request and getting whole page of html response,in that I have included the highchars.js lib

2.现在我在我的产品仪表板页面上,现在我单击具有ajax请求的后退按钮,然后再次单击树节点,在这种情况下,这给了我我的产品仪表板页面我作为错误 未捕获的Highcharts错误#16:www.highcharts.com/errors/16.

2.Right now I am on my product dashboard page,and right now I am clicking on back button which having ajax request,and after that again I am clicking on tree node which gives me my product dashboard page in this situation I am getting error as Uncaught Highcharts error #16: www.highcharts.com/errors/16.

有人可以帮助我克服这种情况吗?

can anybody help me to overcome this situation.

谢谢, 南都.

推荐答案

在同一页面中第二次加载Highcharts或Highstock时,会发生此错误. 这意味着您不应再包含/加载highchart.js文件. 我对此有一个简单的解决方案,这对我来说很好.

This error happens the second time Highcharts or Highstock is loaded in the same page. It means you should not include/load highchart.js file again. I have simple solution over this, and this is working fine for me.

在发送ajax请求时传递一些变量,例如"call"

while sending ajax request pass some variable like 'call'

$.ajax({
    url: "http://www.YourUrlHere.php?key=234&call=ajax", 
    success: function(result){
    $('body').html(result);
    }
   });

在包含/加载highchart.js文件时,请检查是否设置了此变量,如果已设置,则不要再次包含/加载此文件. (belove示例适用于PHP)

And while you include/load highchart.js files check if this variable is set or not, if it is set then don't include/load this files again. (belove example is for PHP)

<?php if(empty($_GET['call'])){ ?>
<script src="assets/Highcharts/code/highcharts.js" type="text/javascript"></script>
<script src="assets/Highcharts/code/modules/exporting.js" type="text/javascript"></script>
<?php } ?>

这篇关于未捕获的Highcharts错误#16:www.highcharts.com/errors/16的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆