Advertisement
Guest User

ajax

a guest
Jul 16th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.94 KB | None | 0 0
  1. $('#dataunitkerja').on('click', '.hapus', function (){
  2.             var Id =  $(this).data('Id');
  3.             swal.fire({
  4.                 title : 'Konfirmasi',
  5.                 text : 'Anda ingin menghapus',
  6.                 type : 'error',
  7.                 showCancelButton : true,
  8.                 confirmButtonText : 'Hapus',
  9.                 confirmButtonColor : '#d33',
  10.                 cancelButtonColor : '#3085d6',
  11.                 cancelButtonText : 'Tidak',
  12.                 reverseButtons : true
  13.             }).then((result) => {
  14.                 if(result.value){
  15.                     $.ajax({
  16.                         url : "<?= site_url('unitkerja/hapusunitkerja') ?>",
  17.                         method : "post",
  18.                         beforeSend : function(){
  19.                             swal.fire({
  20.                                 title : 'Menunggu',
  21.                                 html : 'Memproses Data',
  22.                                 onOpen : () => {
  23.                                     swal.showLoading()
  24.                                 }
  25.                             })
  26.                         },
  27.                         data:{Id:Id},
  28.                         success : function(data){
  29.                             swal.fire({
  30.                                 type : 'success',
  31.                                 title : 'Data Dihapus',
  32.                                 text : 'Anda Berhasil Hapus Data',
  33.                                 timer : 2000,
  34.                             })
  35.                             dataunitkerja.ajax.reload(null, false)
  36.                         }
  37.                     })
  38.                 }else if (result.dismiss === swal.DismissReason.cancel){
  39.                     swal.fire({
  40.                         type : 'warning',
  41.                         title : 'Batal',
  42.                         text : 'Anda Membatalkan',
  43.                         timer : 2000,
  44.                     })
  45.                 }
  46.             })
  47.         });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement