我目前正在使用数据表提供的Ajax函数我只将url更改为我自己的url和列数。这是我得到的错误
未捕获的TypeError:undefined不是函数
$(document).ready(function() {
alert('working');
$('#example').dataTable( {
"processing": true,
"serverSide": false,
"ajax": {
"url": "ViewOwnConsultServ",
"type": "POST"
},
"columns" :
[
{"data" : "lecturename"},
{"data" : "date"},
{"data" : "starttime"},
{"data" : "endtime"},
{"data" : "school"} ,
{"data" : "team"} ,
{"data" : "status"} ,
{"data" : "problem"}
]
} );
} );
这是我的HTML
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Lecturer's Name</th>
<th>Date</th>
<th>Start Time</th>
<th>End Time</th>
<th>School</th>
<th>Team</th>
<th>Status</th>
<th>Teacher's note</th>
</tr>
</thead>
</table>
我怀疑这与我的json有关但我查了一下。下面显示了我的servlet的一个例子。 datatables列是否应该= =我的json字符串的参数个数?
最后这是我的json输出的一个例子
"data":[{"id":0,"staffid":0,"lecturename":"","starttime":"1pm","endtime":"2pm","roomno":0,"school":"Northland Secondary School","team":"northland","status":"Unconfirmed","date":"01/19/2015","problem":" can i PLEASE CONSULT YOU ON MATTER THAT DONT EXIST"},
哦,我忘了这是我的进口
答案 0 :(得分:0)
避免重复脚本对我有用,因为我添加到带有某些js脚本的黑色jsp页面中。因为我没有意识到页面底部还有其他脚本