how to fix datatable fitur dor my ajax data?

how to fix datatable fitur dor my ajax data?

hastahasta Posts: 5Questions: 2Answers: 0

$(document).ready(function(){ tampil_data_riwayat(); //pemanggilan fungsi tampil barang. $('#myTable').DataTable(); function tampil_data_riwayat(){ $.ajax({ type : 'GET', url : '<?php echo base_url()?>riwayat/ambilData', async : true, dataType : 'json', success : function(data){ var html = ''; var i; var no = 0; for(let i = 0; i < data.length; i++){ no++; html += ''+ ''+ no +''+ ''+data[i].nama_pasien+''+ ''+data[i].tanggal+''+ ''+data[i].nama_riwayat+''+ ''+data[i].sakit+''+ ''+data[i].obat+''+ ''+ 'Edit'+' '+ // 'Hapus'+ 'Hapus'+ ''+ ''; } $('#show_data').html(html); } }); } //GET UPDATE $('#show_data').on('click','.item_edit',function(){ var id_riwayat=$(this).attr('data'); $.ajax({ type : "GET", url : "<?php echo base_url('riwayat/get_riwayat')?>", dataType : "JSON", data : {id_riwayat:id_riwayat}, success: function(data){ console.log(data); $.each(data,function(id_riwayat, nama_pasien, tanggal, sakit, obat){ $('#ModalaEdit').modal('show'); $('[name="id_edit"]').val(data[0].id_riwayat); $('[name="nama_edit"]').val(data[0].nama_pasien); $('[name="tanggal_edit"]').val(data[0].tanggal); $('[name="sakit_edit"]').val(data[0].sakit); $('[name="obat_edit"]').val(data[0].obat); }); } }); return false; }); //GET HAPUS $('#show_data').on('click','.item_hapus',function(){ var id_riwayat=$(this).attr('data'); $('#ModalHapus').modal('show'); $('[name="id_riwayat"]').val(id_riwayat); }); //Update Barang $('#btn_update').on('click',function(){ var id_riwayat=$('#id_riwayat2').val(); var nama_pasien=$('#nama_riwayat2').val(); var tanggal=$('#tanggal_riwayat2').val(); var sakit=$('#sakit_riwayat2').val(); var obat=$('#obat_riwayat2').val(); $.ajax({ type : "POST", url : "<?php echo base_url('riwayat/edit_proses')?>", dataType : "JSON", data : {id_riwayat:id_riwayat, nama_pasien:nama_pasien , tanggal:tanggal, sakit:sakit, obat:obat}, success: function(data){ $('[name="id_edit"]').val(""); $('[name="nama_edit"]').val(""); $('[name="tanggal_edit"]').val(""); $('[name="sakit_edit"]').val(""); $('[name="obat_edit"]').val(""); $('#ModalaEdit').modal('hide'); tampil_data_riwayat(); } }); return false; }); //Hapus Barang $('#btn_hapus').on('click',function(){ var id_riwayat=$('#textid_riwayat').val(); $.ajax({ type : "POST", url : "<?php echo base_url('riwayat/hapus_riwayat')?>", dataType : "JSON", data : {id_riwayat: id_riwayat}, success: function(data){ $('#ModalHapus').modal('hide'); tampil_data_riwayat(); } }); return false; }); //Simpan Pasien $('#btn_simpan').on('click',function(){ // var nama_pasien = $this->session->userdata('nama_dokter'); var nama_pasien=$('#nama_pasien').val(); var tanggal=$('#tanggal').val(); var sakit=$('#sakit').val(); var obat=$('#obat').val(); $.ajax({ type : "POST", url : "<?php echo base_url('riwayat/tambah_proses')?>", dataType : "JSON", data : {nama_pasien:nama_pasien , tanggal:tanggal, sakit:sakit, obat:obat}, success: function(data){ $('[name="nama_pasien"]').val(""); $('[name="tanggal"]').val(""); $('[name="sakit"]').val(""); $('[name="obat"]').val(""); $('#ModalaAdd').modal('hide'); tampil_data_riwayat(); } }); return false; }); });

Answers

  • tangerinetangerine Posts: 2,563Questions: 21Answers: 288

    What is your question?

  • colincolin Posts: 8,661Questions: 0Answers: 1,449

    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

  • hastahasta Posts: 5Questions: 2Answers: 0

    sorry, i just new member of this forum. i dont know whats rules to ask question

Sign In or Register to comment.