permanar

Sweet alert

Nov 15th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function() {
  2.   $("#ngehe").click(function() {
  3.     swal({
  4.       title: "Are you sure?",
  5.       text: "Once deleted, you will not be able to recover this data!?",
  6.       icon: "warning",
  7.       buttons: true,
  8.       dangerMode: true,
  9.     })
  10.     .then((willDelete) => {
  11.       if (willDelete) {
  12.         $.ajax({
  13.            type: "GET",
  14.            url: "http://localhost/user/delete", // atau ke bisa ganti disini pake variable
  15.            data: form.serialize(),
  16.            success: function(data) {
  17.                swal({
  18.                  title: "Successfully deleted!",
  19.                  text: "",
  20.                  icon: "success",
  21.                });
  22.            },
  23.            error: function(err) {
  24.              swal({
  25.                title: "Something went wrong!",
  26.                text: "Is it something wrong with your face? I beg you to take a mirror please!",
  27.                icon: "error",
  28.              });
  29.            }
  30.          });
  31.       } else {
  32.          swal({
  33.            title: "You're safe!",
  34.            text: "Data is not deleted. Are you happy?",
  35.            icon: "success",
  36.          });
  37.       }
  38.     });
  39.   });
  40. });
Advertisement
Add Comment
Please, Sign In to add comment