Show data jQuery
Show data jQuery
Danillo Leão Lopes
Posts: 3Questions: 2Answers: 0
I'm try to show data but i have errors
[{
"id": 5,
"nome_fantasia": "Danillo Leão Lopes",
"cnpj_cpf": "600.520.763-69",
"telefone": "(99) 99102-6245",
"pessoa": 1,
"contribuinte": 9
}, {
"id": 6,
"nome_fantasia": "Samuel Fernandes Leão",
"cnpj_cpf": "000.000.000-00",
"telefone": "(00) 00000-0000",
"pessoa": 1,
"contribuinte": 9
}, {
"id": 7,
"nome_fantasia": "Luciane Leão Lopes",
"cnpj_cpf": "000.000.000-00",
"telefone": "(00) 00000-0000",
"pessoa": 1,
"contribuinte": 9
}, {
"id": 8,
"nome_fantasia": "Raimundo Lopes Dias Filho",
"cnpj_cpf": "000.000.000-00",
"telefone": "(00) 00000-0000",
"pessoa": 1,
"contribuinte": 9
}, {
"id": 9,
"nome_fantasia": "Alisson Leão Lopes",
"cnpj_cpf": "000.000.000-00",
"telefone": "(00) 00000-0000",
"pessoa": 1,
"contribuinte": 9
}, {
"id": 10,
"nome_fantasia": "Bruno Leão Lopes",
"cnpj_cpf": "000.000.000-00",
"telefone": "(00) 00000-0000",
"pessoa": 1,
"contribuinte": 9
}]
$.ajax({
url: '/pesquisa/registros/clientes',
data: {
'registros':registros
},
dataType:'json',
success: function(data){
$('#clts').DataTable({
processing:true,
serverSide:true,
data: data,
columns: [
{ title: "#" },
{ title: "Nome" },
{ title: "CNPJ" },
{ title: "Telefone" },
{ title: "#" },
{ title: "#" }
],
})
},
error: function(error){
alert(JSON.stringify(error))
}
})
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I see three issues:
ajax
for server side processing.columns.data
to match the structure of your data. Also review the Data docs for more info.If you don't need server side processing enabled (
serverSide: true,
) then your above code may work with just fixing number 3.Kevin