【发布时间】:2019-04-26 18:17:05
【问题描述】:
我在使用数据表时遇到了一点问题。
我想我已经先用 jquery 声明了我的来源,然后是数据表(我在他们的网站上检索包含最新版本的链接)但是当我加载网页时,我总是有相同的错误消息:
Uncaught SyntaxError: Unexpected token { jQuery.Deferred exception: $ (...)。 DataTable 不是函数 TypeError: $ (...)。数据表是 不是函数 在 HTML 文档。 (https://localhost:44338/事件:87:27) 在 l (https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js:2:29375) 在 c (https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js:2:29677) 未定义
这显然是一个已知问题,经过一番研究我意识到但我仍然无法解决它......
@model IEnumerable<jak.formulaire.Models.Events>
@* Datatable of Events member *@
<table id="example" class="display" style="width:100%">
<thead>
<tr>
<th>Event name</th>
<th>Status</th>
</tr>
</thead>
</table>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
@section Scripts{
<script>
$(document).ready(function () {
$('#example').DataTable();
});
</script>
}
编辑//我发布网络结果的图像。
【问题讨论】:
-
您包含 2 个 jQuery 副本。删除第二个。
-
是的,这就是我强硬的原因,但是当我删除“
-
删除第二个
jquery.js -
谢谢你的帮助,我只有一个 jquery.js 但我只需要将我的引用放在@section Scripts{} 中。
标签: javascript jquery asp.net-mvc datatable datatables