-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
96 lines (91 loc) · 3.79 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<html lang="en-US" dir="ltr">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- <meta name="csrf-token" content="{{ csrf_token() }}" /> -->
<title>Sweetalert2 WIth Loader and AJAX request</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/sweetalert2.min.css" rel="stylesheet">
</head>
<body class="">
<div class="container">
<div class="d-flex justify-content-center">
<button type="button" class="btn btn-large btn-outline-danger" onclick="deletedata('PARAM1','PARAM2','PARAM3')"> Click to Delete Data </button>
</div>
</div>
</body>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/sweetalert2.all.min.js"></script>
<script>
function swal_success(t) {
"use strict";
var e = "Successfull";
t && (e = "" + t), swalWithBootstrapButtons.fire("Successfull", e, "success");
}
function swal_cancelled(t) {
"use strict";
var e = "Something went wrong!!";
t && (e = "" + t), swalWithBootstrapButtons.fire("Ooops!!", e, "error");
}
const swalWithBootstrapButtons = Swal.mixin({
customClass: {
confirmButton: "btn btn-primary mx-2",
cancelButton: "btn btn-outline-danger mx-2",
},
buttonsStyling: !1,
});
function deletedata(param_1,param_2,param_3param_4) {
"use strict";
swalWithBootstrapButtons
.fire({
icon: "warning",
title: "Are you sure to delete the data?",
showCancelButton: !0,
allowOutsideClick: !1,
allowEscapeKey: !1,
confirmButtonText: "Yes, Sure",
cancelButtonText: "No, Cancel it!",
reverseButtons: !0,
showLoaderOnConfirm: !0,
preConfirm: function () {
return new Promise(function (o, n) {
setTimeout(function(){
// Swal.close();
swal_success("Data has been deleted successfully")
// swal_cancelled("Something went wrong!!")
},5000)
// $.ajax({
// type: "DELETE",
// url: "YOUR_AJAX_URL",
// headers: {
// "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
// },
// data:{
// parameter_1:param_1,
// parameter_2:param_2,
// parameter_3:param_3,
// parameter_4:param_4
// },
// success: function (t) {
// if (t.status == 1) {
// swal_success(t.message)
// // location.reload();
// } else {
// swal_cancelled(t.message);
// }
// },
// error: function (t) {
// return swal_cancelled("Something went wrong!!"), !1;
// },
// });
});
},
})
.then((t) => {
t.isConfirmed || (t.dismiss, Swal.DismissReason.cancel);
});
}
</script>
</html>