Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

688
Views
Datatables TypeError: c no está definido

Trato de usar jQuery DataTables pero me sale el error

TypeError: c no está definido

No sé cuál es el problema con mi código, ya que puedo ver que el JSON se recupera correctamente y también tiene el formato correcto, pero no sé cuál es el problema y aparece el error anterior.

Mi JSON:

 {"Data":[{"LOGIN":10184},{"LOGIN":10214},{"LOGIN":10180},{"LOGIN":10187},{"LOGIN":10179},{"LOGIN":10280},{"LOGIN":201},{"LOGIN":10238},{"LOGIN":10296},{"LOGIN":10312}]}

y mi código DataTables:

 $(document).ready(function() { $('#tablename').dataTable( { "processing": true, "serverSide": true, "ajax": { "type": "POST", "url": "https://test.com/api/db/select", "data": function ( json ) { return JSON.stringify( { "Sql": 12 } );}, "contentType": "application/json; charset=utf-8", "dataType": "json", "processData": true, beforeSend : function(xhr){ var access_token = sessionStorage.getItem('access_token'); xhr.setRequestHeader('Authorization', 'Bearer ' + access_token); } }, "dataSrc": "Data", "columns": [ { "data": "LOGIN" } ] } ); } );
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Compruebe si ha agregado

 <thead></thead> <tbody></tbody>

He resuelto este problema agregando esos.

Así que básicamente la estructura debe ser como:

 <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td></td> <td></td> </tr> </tbody> </table>
over 4 years ago · Santiago Trujillo Report

0

En algún momento, este tipo de problema llega al corregir columnas no coincidentes/desiguales con columnas HTML y tablas de datos.

 "columns": [ null, null, null, {"orderable": false, "width":"2%"}, ],

Arriba javascript definió 4 columnas y HTML con 5 columnas

 <tr> <td>A</td> <td>B</td> <td>C</td> <td>D</td> <td>E</td> </tr>

Por lo tanto, tendrá que corregir / igualar la configuración de HTMl y Datatable de ambos lados.

 "columns": [ null, null, null, null, //Added New {"orderable": false, "width":"2%"}, ],
over 4 years ago · Santiago Trujillo Report

0

dataSrc es una opción especial de ajax de tablas de datos, que debe incluirse dentro del objeto ajax:

 "ajax": { "dataSrc": "Data", //<--- place dataSrc here instead "type": "POST", ... }

Lo ha colocado fuera de ajax, y por eso las tablas de datos no tienen idea de qué fuente usar (además de intentar ciegamente la respuesta de ajax) o dónde pertenece LOGIN .

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!