TypeError: $(...)DataTable is not a function
77738 просмотра
2 ответа
I am trying to use the jquery plugin data tables, but I can't seem to load the function. I keep getting this error:
Uncaught TypeError: $(...).DataTable is not a function
(anonymous function) @ index.php:167
m.Callbacks.j @ jquery.min.js:2
m.Callbacks.k.fireWith @ jquery.min.js:2
m.extend.ready @ jquery.min.js:2
J @ jquery.min.js:2
Below is my JS code:
$(document).ready(function(){
$('table#tableID').DataTable({
paging: true
});
});
I am using jQuery V. 1.11.1 I tried to look around for solution, and saw people talking about jQuery not being loaded. I am running other jQuery functions on the same page successfully. This is also the only .ready function on this page. We can tell that jQuery is present, as when the document is ready, it executes the function. I also tried to place the imports of the js and css file in multiple places, as suggested, but did not work. Does anyone have any clue how to fix this?
EDITS:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="/js/jquery.dataTables.js"></script>
Автор: SML
Источник
Размещён: 12.11.2019 09:14
Ответы (2)
13 плюса
Order of scripts is important when they are dependent on libraries or other scripts.
Any jQuery related code needs to be included after jQuery.js... that means plugins and any code you write that uses jQuery. Similarly any code you write that uses a plugin must have the plugin loaded before your code
Simply switch the order so jQuery.js loads before dataTables.js
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" charset="utf8" src="/js/jquery.dataTables.js"></script>
Also make sure you only ever include jQuery once in a page...not once per plugin as some occasionally do
Автор: charlietfl Размещён: 26.07.2015 12:191 плюс
This is because you are loading the jQuery library before loading jQuery itself. jQuery needs to be loaded before you load the library, you can do that by including the <script>
for jQuery before your library:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" charset="utf8" src="/js/jquery.dataTables.js"></script>
Автор: Spencer Wieczorek
Размещён: 26.07.2015 12:18
Вопросы из категории :
- javascript Как определить, какой из указанных шрифтов был использован на веб-странице?
- javascript Валидация клиентской стороны ASP.Net
- javascript Длина объекта JavaScript
- javascript Получение текста из выпадающего списка
- javascript Скрипт входа со скрытыми кнопками
- javascript Как автоматически изменить размер текстовой области с помощью Prototype?
- jquery Прокрутка переполненных DIV с помощью JavaScript
- jquery Экранирование строк HTML с помощью jQuery
- jquery Как сравнить HTML-сущность с JQuery
- jquery Есть ли функция "существует" для jQuery?
- jquery Как удалить все параметры в окне выбора, а затем добавить один вариант и выбрать его с помощью jQuery?
- jquery Получение идентификатора элемента, который вызвал событие
- datatables Как отсортировать по дате с помощью плагинов DataTables jquery?
- datatables использование jquery datatable для обработки на стороне сервера с пейджингом, фильтрацией и поиском
- datatables Как изменить размер JQuery / Datatable после скрытия столбцов
- datatables jQuery DataTables: задержка поиска до 3-х символов или нажатие кнопки
- datatables jatery datatables скрыть столбец
- datatables DataTables с JSON, AJAX и PHP без отображения каких-либо данных