My datable doesn't load the json object
My datable doesn't load the json object
I'm new with Datatable and I don't know how to solve this issue. I've been trying to load an array of objects but it doesn't work. I really appreciate if anybody could help me. Post my code below.
This is my source:
[
{
"contador": 1,
"serie":"3BKHKM9X59F373849",
"placas":"307EW9",
"tipounidad":"TORTON",
"socio":"TRANSPORTES CASTORES S.A. DE C.V. (ESCUELA)",
"noeconomico":"00064",
"marca":"KENWORTH",
"modelo":2009,
"estatus":1,
"km":0
},
{
"contador": 2,
"serie":"3BKHKM9XXJF313957",
"placas":"93AD9M",
"tipounidad":"TORTON",
"socio":"TRANSPORTES CASTORES S.A. DE C.V. (ESCUELA)",
"noeconomico":"00307",
"marca":"KENWORTH",
"modelo":2018,
"estatus":1,
"km":0
},
{
"contador": 3,
"serie":"3BKHKM9X1HF311718",
"placas":"05ABB7L",
"tipounidad":"TORTON",
"socio":"TRANSPORTES CASTORES S.A. DE C.V. (ESCUELA)",
"noeconomico":"00159",
"marca":"KENWORTH",
"modelo":2017,
"estatus":1,"km":0
},
{
"contador": 4,
"serie":"3BKHKM9X0JF314275",
"placas":"55AE4L",
"tipounidad":"TORTON",
"socio":"TRANSPORTES CASTORES S.A. DE C.V. (ESCUELA)",
"noeconomico":"00309",
"marca":"KENWORTH",
"modelo":2018,"estatus":1,"km":0
}
]
Datatable code:
$('#detalle-table').DataTable({
"ajax": {
url: "ajax/cargar_reportedetalle",
type: "POST",
dataType: 'json',
dataSrc: "",
columns: [
{ data: "contador" }
{ data: "noeconomico" },
{ data: "marca" },
{ data: "modelo" },
{ data: "placas" },
{ data: "tipounidad" },
{ data: "socio" },
{ data: "km" },
{ data: "estatus" },
{ data: "serie" }
]
}
});
This question has an accepted answers - jump to answer
Answers
It looks like you have your
columns
option inside theajax
option. You need to move it outside like this:Kevin
Thank you Kevin. Now it works.