【问题标题】:JQuery table won't load., fails to load recourceJQuery 表不会加载。,无法加载资源
【发布时间】:2020-09-02 13:52:44
【问题描述】:

我正在为我的课程制作一个表格,但无法加载来自数据表的精美表格,我只是得到一个无聊的旧 html 表格。

我在我的书中查看了代码,它似乎是相同的。我仍然收到错误 Failed to load resource: net::ERR_FILE_NOT_FOUND

我不知道出了什么问题。 这是代码

<!DOCTYPE html>
<html>
<head>   
    <link rel="stylesheet" href="C:\Users\bas_t\OneDrive\Code Educom\JQuery\JQuery\style.css"/>
    <link rel="stylesheet" href="//cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css"/>
    <script src="js/jquery.js" />
    <script src="//cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"/>

    <script>
      $(document).ready( function() {
        $('#theBeatles').DataTable();
      })   
    </script>
</head>
  
  <body>
    
     <table id="theBeatles" 
            class="display nowrap dataTable dtr-inline collapsed">
        <thead>
            <th>Name</th>
            <th>Email</th>
            <th>Instrument</th>
        </thead>
        <tbody>
            <tr>
                <td>John Lennon</td>
                <td>john@thebeatles.co.uk</td>
                <td>Guitar</td>
            </tr>
            <!-- and so on with the other members --> 
        </tbody>
        </table>
        </body>
        </html>

【问题讨论】:

    标签: javascript jquery datatables


    【解决方案1】:

    您的 html 无效,CSS 的文件路径可能无效

    做这些事情

    1. 删除自闭合脚本标签并转换为&lt;script&gt; your file &lt;/script&gt; - Why?
    2. 您正在尝试加载本地 css 文件 - 这可能无法有效工作,请尝试从本地服务器提供它 - 我可以建议 serve 或将 CSS 文件的值粘贴到 &lt;style&gt; 标记中

    祝你好运!

    【讨论】:

    • 谢谢,我还需要在链接中添加 https:,现在可以使用了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-28
    • 2014-03-26
    • 2019-07-13
    • 2017-05-02
    • 2017-12-11
    • 1970-01-01
    • 2014-07-26
    相关资源
    最近更新 更多