DataTable JSON
HTML
<table class="table table-responsive filter-head" id="lista">
<thead>
<tr>
<th>ID</th>
<th>E-mail</th>
<th>Nome</th>
<th>Cognome</th>
<th>Lingua</th>
<th>Stato</th>
<th></th>
</tr>
</thead>
<tbody></tbody>
</table>
JavaScript
$( document ).ready(function() {
var jqxhr = $.ajax({url: api_ricercautente_nl, type: "GET",dataType: "json", data: { type: "ricerca_utenti"}} )
.done(function(json) {
var table = $('#lista').DataTable( {
destroy: true,
retrieve: true
} );
for (i=0;i<json.utenti.length;i++){
var status=""; if (json.utenti[i].unsubscribe == 0) status = "Iscritto"; else status = "Disiscritto";
var nome=""; if (json.utenti[i].nome == '') nome = ""; else nome = json.utenti[i].nome;
var cognome=""; if (json.utenti[i].cognome == '') cognome = ""; else cognome = json.utenti[i].nome;
var rowNode = table
.row.add( [json.utenti[i].id,json.utenti[i].email,json.utenti[i].nome,json.utenti[i].cognome,json.utenti[i].lingua,status,"<a href='/newsletter/user.php?id="+json.utenti[i].id+"&email="+json.utenti[i].email+"' target='_blank'>dettagli</a>"] )
.draw()
.node();
}
})
.fail(function() {
alert( "error" );
});
});