how to reload if building a data table with dom jquery?

how to reload if building a data table with dom jquery?

khoirul.miftahulkhoirul.miftahul Posts: 1Questions: 1Answers: 0

function tabel_lokasi(){
$.ajax({
type : 'ajax',
url : site+"master/Get_Lokasi",
async : false,
dataType : 'json',
success : function(data){
var html = '<thead><tr><th class="col-md-1">#</th><th class="col-md-3">Cabang Pembina</th><th class="col-md-4">Lokasi </th>'+
'<th class="col-md-2">Icao Code</th><th class="col-md-2">Aksi</th></tr></thead><tbody>';
var i;
var no = 0;
for(i=0; i<data.length; i++){
no++;
html += '<tr>'+
'<td>'+no+'</td>'+
'<td>'+data[i].DescCabang+'</td>'+
'<td>'+data[i].DescLokasi+'</td>'+
'<td>'+data[i].IcaoCode+'</td>'+
'<td><button type="button" name="update" id="'+data[i].IdLokasi+'" class="btn btn-rounded btn-warning btn-sm ubah" title="ubah"><i class="fa fa-edit"></i></button>'+
'<button type="button" name="delete" id="'+data[i].IdLokasi+'" class="btn btn-rounded btn-danger btn-sm hapus" title="hapus"><i class="fa fa-trash-o"></i></button></td>'+
'</tr>';
}
html = html + '</tbody>';
$('#TabelLokasi').html(html);
$("#TabelLokasi").DataTable();
}

    });

}

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.