0

Buena noche tengo un problema, estoy tratando de utilizar el cdn de datatables y cuando quiero hacer una tabla no me carga las funciones de paginacion y búsqueda en la datatable, y no tengo idea de cual es el problema aparece en este formato: introducir la descripción de la imagen aquí

asi es como se deberia de ver introducir la descripción de la imagen aquí

estos errores me salen en cosola cuando inspeciono

introducir la descripción de la imagen aquí

el código que utilizo es este de la llamada de los cdn desde la pagina son:

<!--datatables -->
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>

<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>

<!--bootstrap-->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

<table id="example" class="display" style="width:100%">
    <thead>
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Tiger Nixon</td>
            <td>System Architect</td>
            <td>Edinburgh</td>
            <td>61</td>
            <td>2011/04/25</td>
            <td>$320,800</td>
        </tr>
        <tr>
            <td>Garrett Winters</td>
            <td>Accountant</td>
            <td>Tokyo</td>
            <td>63</td>
            <td>2011/07/25</td>
            <td>$170,750</td>
        </tr>
        <tr>
            <td>Ashton Cox</td>
            <td>Junior Technical Author</td>
            <td>San Francisco</td>
            <td>66</td>
            <td>2009/01/12</td>
            <td>$86,000</td>
        </tr>

    </tbody>
    <tfoot>
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
        </tr>
    </tfoot>
</table>



<script type="text/javascript">
$(document).ready(function() {
$('#example').DataTable();
} );
</script>
</body>
</html>

1 respuesta 1

2

El error que tenes es claro,

ReferenceError: jQuery is not defined

Se esta provocando porque en la línea 3

<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>

Estas intentando cargar un plugin que es dependiente de jQuery sin haberlo cargado previamente.

¿La solución?

Cargar jQuery antes de DataTables

<!--datatables -->
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<!--bootstrap-->
....
.....
1
  • Gracias amigo efectivamente ese era el problema. el 19 dic. 2018 a las 0:04

Tu Respuesta

Al pulsar en “Publica tu respuesta”, muestras tu consentimiento a nuestros términos de servicio, política de privacidad y política de cookies

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.