TypeError: data is undefined
TypeError: data is undefined
mldgato
Posts: 13Questions: 3Answers: 0
Hi, I have this error: TypeError: data is undefined
this is my javascript code:
$(document).ready(function()
{
var tabla = $('#LosUsuarios').dataTable(
{
"processing": true,
"serverSide": true,
"ajax":
{
"url": "listadoUsuarios.php",
"type": "POST"
},
"columns": [
{ "Usuarios": "Nombres" },
{ "Usuarios": "Apellidos" },
{ "Usuarios": "Usuario" },
{ "Usuarios": "Email" },
{ "Usuarios": "Rol" }
]
});
});
My json result is:
{"Usuarios":[{"Nombres":"Manuel Lisandro","Apellidos":"Dardón López","Usuario":"mldgato","Email":"manueldardon@hotmail.com","Rol":"1"},{"Nombres":"Luisa María","Apellidos":"Pérez Rodríguez","Usuario":"lperez","Email":"lperez@manueldardon.net","Rol":"2"},{"Nombres":"Walter Antonio","Apellidos":"Ceballos Carranza","Usuario":"wceballos","Email":"wceballos@manueldardon.net","Rol":"3"},{"Nombres":"Cesar Sebastían","Apellidos":"Domínguez Contreras","Usuario":"cdominguez","Email":"cdominguez@gmail.com","Rol":"3"},{"Nombres":"Maria Silvia","Apellidos":"Estrada Morales","Usuario":"mestrada","Email":"mestrada@gmail.com","Rol":"3"}]}
you can see in:
sigeco.manueldardon.net/usuarios/listadoUsuarios.php
I followed the following example:
https://datatables.net/examples/server_side/post.html
But it does not work, someone can guide me please
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
the Json is valid.
where is the page with the JS code and the html table?
There is no
Usuarios
property in DataTables. I think you mean:Also use the
ajax.dataSrc
option set to beUsuarios
to tell DataTables that is where the data array in your JSON is.Allan
Thanks Allan, it worked by changing the name of the array with data, but the searcher and pagination does not work
Well the searcher and pagination works, I removed the part of processing with the server, thank you very much.