Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 为什么拉斐尔js图形不';无法使用.html()工作_Jquery_Raphael - Fatal编程技术网

Jquery 为什么拉斐尔js图形不';无法使用.html()工作

Jquery 为什么拉斐尔js图形不';无法使用.html()工作,jquery,raphael,Jquery,Raphael,我的代码有问题。代码将显示表格,但不显示图形some.php位于名为bin的文件夹中,而js也位于该文件夹中我真的不知道为什么当我尝试直接查看some.php时它不起作用图形会显示,但当我单击index.php上的按钮时,没有显示图形,我也试着把bin/js/js链接放到js链接上,但结果是我无法再点击按钮2。有人能告诉我为什么会发生这种情况吗?或者有人能给我举个我可以研究的例子吗 index.php <!DOCTYPE html> <html> <head>

我的代码有问题。代码将显示表格,但不显示图形some.php位于名为bin的文件夹中,而js也位于该文件夹中我真的不知道为什么当我尝试直接查看some.php时它不起作用图形会显示,但当我单击index.php上的按钮时,没有显示图形,我也试着把bin/js/js链接放到js链接上,但结果是我无法再点击按钮2。有人能告诉我为什么会发生这种情况吗?或者有人能给我举个我可以研究的例子吗

index.php

<!DOCTYPE html>
<html>
<head>
  <style>
  p { color:red; margin:4px; }
  b { color:blue; }
  </style>
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>

</head>
<body>

 <div class="action-button">
    <button id="1" value="1074">Button 1</button>
    <button id="2" value="1074">Button 2</button>
 </div>

  <div id="output"></div>

<script>
    $("button").click(function () {
      var attr = $(this).attr("id");
      var val = $(this).val();

     $.ajax({
     type: "POST",
      url: "bin/some.php",
      data: { lookbookID: attr, type: val }
    }).done(function( html ) {
      $("#output").html(attr + ' - ' +  val + ' - ' + html);
    });
});
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Raphaël · Analytics</title>
        <link rel="stylesheet" href="demo.css" type="text/css" media="screen">
        <link rel="stylesheet" href="demo-print.css" type="text/css" media="print">
        <script src="js/raphael.js"></script>
        <script src="js/popup.js"></script>
        <script src="js/jquery.js"></script>
        <script src="js/analytics.js"></script>

    </head>
    <body>
<?php 
echo "lookbookID: ".$_POST['lookbookID']." - "; 
echo " type: ".$_POST['type']
?>
        <table id="data">
            <tfoot>
                <tr>
                    <th>1</th>
                    <th>2</th>
                    <th>3</th>
                    <th>4</th>
                    <th>5</th>
                    <th>6</th>
                    <th>7</th>
                    <th>8</th>
                    <th>9</th>
                    <th>10</th>
                    <th>11</th>
                    <th>12</th>
                    <th>13</th>
                    <th>14</th>
                    <th>15</th>
                    <th>16</th>
                    <th>17</th>
                    <th>18</th>
                    <th>19</th>
                    <th>19</th>
                    <th>20</th>
                    <th>22</th>
                    <th>23</th>
                    <th>24</th>
                    <th>25</th>
                    <th>26</th>
                    <th>27</th>
                    <th>28</th>
                    <th>29</th>
                    <th>30</th>
                    <th>31</th>
                </tr>
            </tfoot>
            <tbody>
                <tr>
                    <td>8</td>
                    <td>25</td>
                    <td>27</td>
                    <td>25</td>
                    <td>54</td>
                    <td>59</td>
                    <td>79</td>
                    <td>47</td>
                    <td>27</td>
                    <td>44</td>
                    <td>44</td>
                    <td>51</td>
                    <td>56</td>
                    <td>83</td>
                    <td>12</td>
                    <td>91</td>
                    <td>52</td>
                    <td>12</td>
                    <td>40</td>
                    <td>8</td>
                    <td>60</td>
                    <td>29</td>
                    <td>7</td>
                    <td>33</td>
                    <td>56</td>
                    <td>25</td>
                    <td>1</td>
                    <td>78</td>
                    <td>70</td>
                    <td>68</td>
                    <td>2</td>
                </tr>
                </tbody>
            </table>
           <div id="holder"></div>

    </body>
</html>

p{颜色:红色;边距:4px;}
b{颜色:蓝色;}
按钮1
按钮2
$(“按钮”)。单击(函数(){
var attr=$(this.attr(“id”);
var val=$(this.val();
$.ajax({
类型:“POST”,
url:“bin/some.php”,
数据:{lookbookID:attr,type:val}
}).done(函数(html){
$(“#输出”).html(attr+'-'+val+'-'+html);
});
});
some.php文件

<!DOCTYPE html>
<html>
<head>
  <style>
  p { color:red; margin:4px; }
  b { color:blue; }
  </style>
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>

</head>
<body>

 <div class="action-button">
    <button id="1" value="1074">Button 1</button>
    <button id="2" value="1074">Button 2</button>
 </div>

  <div id="output"></div>

<script>
    $("button").click(function () {
      var attr = $(this).attr("id");
      var val = $(this).val();

     $.ajax({
     type: "POST",
      url: "bin/some.php",
      data: { lookbookID: attr, type: val }
    }).done(function( html ) {
      $("#output").html(attr + ' - ' +  val + ' - ' + html);
    });
});
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Raphaël · Analytics</title>
        <link rel="stylesheet" href="demo.css" type="text/css" media="screen">
        <link rel="stylesheet" href="demo-print.css" type="text/css" media="print">
        <script src="js/raphael.js"></script>
        <script src="js/popup.js"></script>
        <script src="js/jquery.js"></script>
        <script src="js/analytics.js"></script>

    </head>
    <body>
<?php 
echo "lookbookID: ".$_POST['lookbookID']." - "; 
echo " type: ".$_POST['type']
?>
        <table id="data">
            <tfoot>
                <tr>
                    <th>1</th>
                    <th>2</th>
                    <th>3</th>
                    <th>4</th>
                    <th>5</th>
                    <th>6</th>
                    <th>7</th>
                    <th>8</th>
                    <th>9</th>
                    <th>10</th>
                    <th>11</th>
                    <th>12</th>
                    <th>13</th>
                    <th>14</th>
                    <th>15</th>
                    <th>16</th>
                    <th>17</th>
                    <th>18</th>
                    <th>19</th>
                    <th>19</th>
                    <th>20</th>
                    <th>22</th>
                    <th>23</th>
                    <th>24</th>
                    <th>25</th>
                    <th>26</th>
                    <th>27</th>
                    <th>28</th>
                    <th>29</th>
                    <th>30</th>
                    <th>31</th>
                </tr>
            </tfoot>
            <tbody>
                <tr>
                    <td>8</td>
                    <td>25</td>
                    <td>27</td>
                    <td>25</td>
                    <td>54</td>
                    <td>59</td>
                    <td>79</td>
                    <td>47</td>
                    <td>27</td>
                    <td>44</td>
                    <td>44</td>
                    <td>51</td>
                    <td>56</td>
                    <td>83</td>
                    <td>12</td>
                    <td>91</td>
                    <td>52</td>
                    <td>12</td>
                    <td>40</td>
                    <td>8</td>
                    <td>60</td>
                    <td>29</td>
                    <td>7</td>
                    <td>33</td>
                    <td>56</td>
                    <td>25</td>
                    <td>1</td>
                    <td>78</td>
                    <td>70</td>
                    <td>68</td>
                    <td>2</td>
                </tr>
                </tbody>
            </table>
           <div id="holder"></div>

    </body>
</html>

拉斐尔·分析学
1.
2.
3.
4.
5.
6.
7.
8.
9
10
11
12
13
14
15
16
十七,
18
19
19
20
22
23
24
25
26
27
28
29
30
31
8.
25
27
25
54
59
79
47
27
44
44
51
56
83
12
91
52
12
40
8.
60
29
7.
33
56
25
1.
78
70
68
2.

您的方法有两个问题

  • ajax请求检索整个文档,您正试图将其注入页面中。你不应该那样做
  • html方法为了安全起见去掉了所有JavaScript标记,因此不会执行js
  • 你可能可以通过尝试使用

    $("#output")[0].innerHtml = attr + ' - ' +  val + ' - ' + html
    
    这在某些浏览器中可能有效,但正如我已经指出的,这是无效的。由于它是一个完整的文档,您可以尝试使用iframe,或者修改php以只返回一段html而不是完整的文档