Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/415.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
Javascript jquery错误:未捕获的TypeError:$(…)。DataTable不是函数_Javascript_Jquery_Html_Twitter Bootstrap - Fatal编程技术网

Javascript jquery错误:未捕获的TypeError:$(…)。DataTable不是函数

Javascript jquery错误:未捕获的TypeError:$(…)。DataTable不是函数,javascript,jquery,html,twitter-bootstrap,Javascript,Jquery,Html,Twitter Bootstrap,我尝试使用以下示例引导可排序表代码: 我的html中有html/css/和jquery,但每当我加载页面时,控制台中就会出现错误: 我在网上找到的所有关于这个错误的帖子都指向jquery被多次加载,但我下面的html文件只在标题中加载jquery一次,就像bootstrap所说的那样。是什么导致我的jquery错误阻止对表进行排序?谢谢 //表排序 $(文档).ready(函数(){ $('#dtBasicExample').DataTable(); $('.dataTables_leng

我尝试使用以下示例引导可排序表代码:

我的html中有html/css/和jquery,但每当我加载页面时,控制台中就会出现错误:

我在网上找到的所有关于这个错误的帖子都指向jquery被多次加载,但我下面的html文件只在标题中加载jquery一次,就像bootstrap所说的那样。是什么导致我的jquery错误阻止对表进行排序?谢谢

//表排序
$(文档).ready(函数(){
$('#dtBasicExample').DataTable();
$('.dataTables_length').addClass('bs-select');
});
函数更新_数据(){
$.ajax({
方法:“张贴”,
url:“/popularify\u updatePage/”,
数据:{},
成功:功能(数据){
console.log(data)//检查数据的结构
//更新硬币数量
$('.popularifyDataDiv').contents()[0].textContent=data
//数据。硬币
}
})
};
异步函数myFunction(){
console.log(“myFunction()”)
//向python函数发出post请求
var csrftoken=getCookie('csrftoken');
var artistURI=document.getElementById(“artistURI输入”).value;
console.log(“artistURI=”,artistURI)
let successValue=等待makeAjax(artistURI,csrftoken);
console.log(“successValue=”,successValue)
document.getElementById(“demo”).innerHTML=successValue;
var jsonData=JSON.parse(successValue)
console.log(jsonData)
var numberOfEntries=Object.keys(jsonData.data).length
console.log(numberOfEntries)//Object.keys(jsonData.data.length)
console.log(“popularify data=“,numberOfEntries中的numberOfEntries”)
var table=document.getElementById(“displayTable”);
对于(var i=0;i

添加
cdn.datatables.net/1.10.20/js/jquery.datatables.min.js
,这是@Vineesh注释的datatables库。检查此项

//表排序
$(文档).ready(函数(){
$('#dtBasicExample').DataTable();
$('.dataTables_length').addClass('bs-select');
});
函数更新_数据(){
$.ajax({
方法:“张贴”,
url:“/popularify\u updatePage/”,
数据:{},
成功:功能(数据){
console.log(data)//检查数据的结构
//更新硬币数量
$('.popularifyDataDiv').contents()[0].textContent=data
//数据。硬币
}
})
};
异步函数myFunction(){
console.log(“myFunction()”)
//向python函数发出post请求
var csrftoken=getCookie('csrftoken');
var artistURI=document.getElementById(“artistURI输入”).value;
console.log(“artistURI=”,artistURI)
let successValue=等待makeAjax(artistURI,csrftoken);
console.log(“successValue=”,successValue)
document.getElementById(“demo”).innerHTML=successValue;
var jsonData=JSON.parse(successValue)
console.log(jsonData)
var numberOfEntries=Object.keys(jsonData.data).length
console.log(numberOfEntries)//Object.keys(jsonData.data.length)
console.log(“popularify data=“,numberOfEntries中的numberOfEntries”)
var table=document.getElementById(“displayTable”);
对于(var i=0;i

检查您是否有一个基于空值生成的空列。尝试在提到的列上输入“NULL”。

您没有在源代码中包含
datatable.js
我看到您正在加载jquery slim 3.3.1,我看到您的错误消息指示从google的CDN加载的3.4.1。看起来像是“jquery的多个版本”我有问题