I have this error in my datatable, I have tried everything and without success so far, below is the error:
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pacientes</title>
<link rel="stylesheet" href="https://cdn.datatables.net/2.0.8/css/dataTables.dataTables.css">
</head>
<body>
<h1>LISTAR USUARIOS</h1>
<table id="listar-usuario" class="display" style="width:100%">
<thead>
<tr>
<th>Nome</th>
<th>Contato</th>
<th>Exame</th>
<th>Dia</th>
<th>Hora</th>
<th>Açoes</th>
</tr>
</thead>
</table>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdn.datatables.net/2.0.8/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/2.0.8/css/jquery.dataTables.min.css">
<script>
new DataTable('#listar-usuario', {
ajax: 'listar_usuarios.php',
processing: true,
serverSide: true
});;
</script>
</body>
</html>
I managed to select part of the error by changing the position of the scripts, jquery has to go above the table, but I still get the following error:
Uncaught ReferenceError: DataTable is not defined
I know it’s clear saying that my table is not defined, I’ve already tried defining it in different ways and without success.
Recognized by PHP Collective
New contributor
Lucas Silva is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2