当我点击删除按钮时,它会弹出 - 如果我选择"是"然后将显示成功消息"模块已被删除"。
$(document).ready(function () {
$("#example tbody").on('click', '.user-Delete', function (e) {
e.preventDefault();
var getId = $(this).data('id');
swal({
title: "Are you sure?",
text: "You will not be able to recover this Module!",
type: "warning",
showCancelButton: true,
confirmButtonClass: "btn-danger",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel it!",
closeOnConfirm: false,
closeOnCancel: false
},
function (isConfirm) {
if (isConfirm) {
$.ajax({
type: 'POST',
url: '@Url.Action("DeleteModule")',
dataType: 'json',
data: {
ModuleID: getId
},
success: function (data) {
if (data.success) {
swal({
title: "Deleted!",
text: "Module has been deleted.",
type: "success",
confirmButtonClass: "btn-success",
});
}
},
error: function (ex) {
alert('Failed to retrieve Sub Categories : ' + ex);
}
});
} else {
swal({
title: "Cancelled",
text: "Module Record is safe :)",
type: "error",
confirmButtonClass: "btn-danger"
});
}
});
});
});
如果我选择确定按钮,则在消息弹出窗口内,只有页面应该刷新。
点击OK
然后刷新页面
答案 0 :(得分:2)
您可以使用:
window.location.reload();

答案 1 :(得分:1)
试试这个:
success: function (data) {
if (data.success) {
swal({
title: "Deleted!",
text: "Module has been deleted.",
type: "success",
confirmButtonClass: "btn-success",
},
function(){
location.reload();
});
}
}
答案 2 :(得分:1)
尝试将此添加到成功块中的swal()调用中:
success: function (data) {
if (data.success) {
swal({
title: "Deleted!",
text: "Module has been deleted.",
type: "success",
confirmButtonClass: "btn-success",
})
.then(function() {
location.reload();
});
}
},
答案 3 :(得分:0)
您可以在ok按钮上单击
使用以下javascript功能
alert("page refresh")
function refresh() {
setTimeout(function () {
location.reload()
}, 100);
}

<input type="submit" value="ok" id="submit" onclick="refresh()">
&#13;