$(document).ready(function() { tampil_data_item(); $('#table_matkul').DataTable(); function tampil_data_item() { var user = $('#username_').html(); $.ajax({ type: 'ajax', url: window.location.origin + '/dosen/get_dhmd_clear_bydosen/'+user, async: false, dataType: 'json', success: function(data) { var html = ''; for (var i = 0; i < data.length; i++) { var thn = data[i].kdstsemester.slice(0,4); var thn2 = parseInt(data[i].kdstsemester.slice(0,4)) + 1; var smster = ''; if(data[i].kdstsemester.slice(4,5) == '1') smster = 'ganjil'; else if(data[i].kdstsemester.slice(4,5) == '2') smster = 'genap'; html += '' + '' + (i + 1) + '' + '' + data[i].kdmk + '' + '' + data[i].matkul + '' + '' + data[i].kelas + '' + '' + thn+'/'+thn2+'-'+smster + '' + '' + data[i].pertemuan + '' + ''; } $('#show_data').html(html); } }); } });