Advertisement
hamjoricantiq

Untitled

Jan 21st, 2020
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2.         $(function() {
  3.             $(".btnDelete").on("click", function(e) {
  4.                 e.preventDefault();
  5.  
  6.                 var nama_lengkap = $(this).parent().parent().children()[2];
  7.                 nama_lengkap = $(nama_lengkap).html();
  8.  
  9.                 var tr = $(this).parent().parent();
  10.  
  11.                 $(".modal").modal('show');
  12.                 $(".modal-title").html('Konfirmasi');
  13.                 $(".modal-body").html('Anda yakin ingin menghapus data <b>' +nama_lengkap+ '</b> ?');
  14.  
  15.                 var href = $(this).attr('href');
  16.  
  17.                 $('.btnYa').off();
  18.                 $('.btnYa').on('click', function() {
  19.                     $.ajax({
  20.                         'url'       : href,
  21.                         'type'      : 'POST',
  22.                         'success'   : function(result) {
  23.                             if (result == 1) {
  24.                                 $(".modal").modal('hide');
  25.                                 tr.fadeOut();
  26.  
  27.                                 toastr.success('Data berhasil dihapus', 'Informasi')
  28.                             }
  29.                         }
  30.                     });
  31.                 });
  32.             });
  33.         });
  34.     </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement