dsi37923 2015-05-11 08:40
浏览 80

在另一个页面中包含canvasJS图表

I don't know why I can't include a canvasJS with JavaScript on another page.

<script type="text/javascript">
    $(document).ready(function() {
        $("input[name='btn']").click(function() {
            var vValue = document.getElementById("value").value;
            var testValue = document.getElementById("test").value;
            var projValue = document.getElementById("project").value;               
            $("#parent").load('/index.php/grafic/view/proiect1/1/2');
        });
    });
</script>

I use those values (vValue, testValue, projValue) but in this case I was trying a test: if the values are correct I use an .alert() to see if it takes these values. On the page index.php/grafic/view/project1/1/2 I have a canvasJS graphic that works if I enter on that page.

A part of my JS code:

<script type="text/javascript">
                window.onload = function () {
                    var chart = new CanvasJS.Chart("chartContainer",
                        {
                            exportEnabled: true,
                            title:{
                                text: "<?php echo $nume; ?>"
                            },
                            axisY:{
                                title:"Number of runs"
                            },
                            legend: {
                            ---//---


                             </script>
            <script type="text/javascript" src="/css/canvasjs.min.js"></script>
            <div id="chartContainer" style="height: 300px; width: 1100px;"></div>

So my problem is that after I click the button, in the parent div that chart will not appear, but if I write some text on that page, it will show in the parent div.

  • 写回答

1条回答 默认 最新

  • doutangguan2460 2015-06-03 21:58
    关注

    I think, the problem is that you are using window.onload and this function never will be executed because the page is loading by ajax(.load function) Try to use jquery load-event instead

    评论

报告相同问题?

悬赏问题

  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 github训练的模型参数无法下载
  • ¥15 51单片机显示器问题
  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案
  • ¥50 winform中使用edge的Kiosk模式
  • ¥15 关于#python#的问题:功能监听网页
  • ¥15 怎么让wx群机器人发送音乐
  • ¥15 fesafe材料库问题