我想confirm()
用著名的甜蜜警报插件在 JavaScript 上实现一个。但不知何故甜蜜警报不起作用。
这是我的代码:
function kendaraan(param) {
if (swal({
title: "Are you sure?",
text: "You wanna leave this page?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, Leave!",
closeOnConfirm: false
},
function(){
})
){
switch (param) {
case "ADD_KENDARAAN" :
$.ajax({
type: "POST",
url: "pages/lj_menu/vehicle/add_vehicle.php",
success: function (response, textStatus, jqXHR) {
$('#lj-mainpage').html(response);
}
});
break;
}
}
}
所以我的意图是当用户单击“添加 KENDARAAN”时,它应该显示甜蜜的警报确认,当用户单击是时,然后执行 ajax 部分。