Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $("#table-laporan").on("click", ".btn-delete", function () {
- Swal.fire({
- title: "Anda yakin?",
- text: "Anda yakin ingin menghapus data?",
- icon: "warning",
- showCancelButton: true,
- confirmButtonColor: "#3085d6",
- cancelButtonColor: "#d33",
- confirmButtonText: "Yes, delete it!",
- allowOutsideClick: false,
- }).then((result) => {
- if (result.value) {
- Swal.fire({
- imageUrl: base_url + "/images/loading.png",
- imageHeight: 300,
- showConfirmButton: false,
- title: "Loading ...",
- allowOutsideClick: false,
- });
- var idLaporan = $(this).data("id");
- var urlDelete =
- base_url + "/client/laporan/" + idLaporan + "/delete";
- $.ajax({
- url: urlDelete,
- type: "DELETE",
- contentType: false,
- processData: false,
- success: function (data) {
- Swal.fire({
- icon: "success",
- title: data.data.message,
- showConfirmButton: false,
- timer: 2000,
- allowOutsideClick: false,
- }).then(function () {
- refreshTable();
- });
- },
- error: function (jqXHR, textStatus, errorThrown) {
- var error = jqXHR.responseJSON;
- if (error.meta) {
- var message = error.meta.message;
- } else {
- var message = error.message;
- }
- Swal.fire({
- icon: "error",
- title: message,
- showConfirmButton: false,
- timer: 2000,
- allowOutsideClick: false,
- });
- },
- });
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement