im trying to to make use of the datatables but when is supossed to draw the table the response is:
DataTables warning: table id=tablaSucursales - Requested unknown parameter '0' for row 0, column 0
And it appears two times
My object response is like this
{
Mensaje: "OK"
"Data": [
{
"Id_Sucursal": 510001,
"Nombre_Sucursal": "Pedestal Prueba",
"Estado": "CDMX",
"Activa": 0
},
{
"Id_Sucursal": 510010,
"Nombre_Sucursal": "Tableta de Pruebas",
"Estado": "CDMX",
"Activa": 0
},
]
}
My ajax request and datatables initialization is like this
$.ajax({
url: './Archivos_Ajax.asp',
method: "POST",
dataType: 'json',
data: { accion: "ObtenerSucursales",
PageNumber: 1,
RowsOfPage: 20 },
success: function (response) {
$('#tablaSucursales').DataTable( {
// "processing": true,
// "serverSide": true,
data: response.Data,
// search: {
// return: true
// },
columns: [
{title: "Id_Sucursal" },
{title: "Nombre_Sucursal"},
{title: "Estado"},
{title: "Activa"}
]
} );
}
});
I already validate the Data object with https://jsonlint.com/
Any help would be awesome
columns.title. You need to usecolumns.data. And if you have trouble finding those references for yourself, then start by looking at the examples - especially the Ajax examples - and the one which uses JSON data objects, the same as your data source.datawith a lower case "d" not upper case in your array.