sweetalert2 delete confirmation site:stackoverflow.com

      <script src="<?php echo base_url(); ?>sweetalert2/dist/sweetalert2.all.min.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/promise-polyfill"></script>
      <script src="<?php echo base_url(); ?>sweetalert2/dist/sweetalert2.min.js"></script>
      <link rel="stylesheet" href="<?php echo base_url(); ?>assets/sweetalert2/dist/sweetalert2.min.css"> 

      <script type="text/javascript">

      function hapus() {  
      event.preventDefault(); 
      var form = event.target.form; 
      Swal.fire({
      title: 'Are you sure?',
      text: "You won't be able to revert this!",
      icon: 'warning',
      showCancelButton: true,
      confirmButtonColor: '#3085d6',
      cancelButtonColor: '#d33',
      confirmButtonText: 'Yes, delete it!'
    }).then((result) => {
      if (result.value) {
        Swal.fire(
          'Deleted!',
          'Your file has been deleted.',
          'success'
        )
      }
    })}
    </script>

0
9
Rena Ayad 105 points

                                    function hapus($___id) {  
  swal.fire({
        title: 'Are you sure?',
        text: &quot;Are you sure you want to proceed ?&quot;,
        type: 'warning',
        showCancelButton: true,
        confirmButtonText: 'Yes'
    }).then(function(result) { 
        if (result.value) {
            $.ajax({
                url : `postingan/hapus/${$___id}`,
                type : 'GET',
                dataType:'json',
                beforeSend: function() {
                    swal.fire({
                        title: 'Please Wait..!',
                        text: 'Is working..',
                        onOpen: function() {
                            swal.showLoading()
                        }
                    })
                },
                success : function(data) { 
                    swal.fire({
                        position: 'top-right',
                        type: 'success',
                        title: 'User  deleted successfully',
                        showConfirmButton: false,
                        timer: 2000
                    });
                 },
                complete: function() {
                    swal.hideLoading();
                },
                error: function(jqXHR, textStatus, errorThrown) {
                    swal.hideLoading();
                    swal.fire(&quot;!Opps &quot;, &quot;Something went wrong, try again later&quot;, &quot;error&quot;);
                }
            });
        }
    });
}

0
0
Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source