Advertisement
Rofihimam

Untitled

Jan 22nd, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. <script type="text/javascript">
  2.     $(function() {
  3.         $(".btnDelete").on("click", function(e) {
  4.             e.preventDefault();
  5.  
  6.             var nama = $(this).parent().parent().children()[3];
  7.             nama = $(nama).html();
  8.  
  9.             var tr = $(this).parent().parent();
  10.  
  11.             $(".modal").modal('show');
  12.             $(".modal-title").html('Konfirmasi');
  13.             $(".modal-body").html('Apa anda yakin ingin menghapus data <b>' + nama + '</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