Bước 1: Viết chức năng của riêng bạn cho cảnh báo bật lên với nút ok (tôi đã tạo chức năng tham số hóa chấp nhận thông báo, loại cảnh báo, tên phương thức.
chức năng AlertMessageOk (str, alertType, phương pháp)
{
$('#AlertMessage .divDialogElements').empty();
$('#AlertMessage .divDialogElements').append(msg);
if (alertType == "success") {
$('#AlertMessage #modalAlertHeaderTitle').html("Success");
$('#AlertMessage #modalAlertHeaderTypeClass').attr("class", "modal-header alert-success");
}
else if (alertType == "error") {
$('#AlertMessage #modalAlertHeaderTitle').html("Error");
$('#AlertMessage #modalAlertHeaderTypeClass').attr("class", "modal-header alert-danger");
}
else if (alertType == "info") {
$('#AlertMessage #modalAlertHeaderTitle').html("Status");
$('#AlertMessage #modalAlertHeaderTypeClass').attr("class", "modal-header alert-info");
}
else if (alertType == "warning") {
$('#AlertMessage #modalAlertHeaderTitle').html("Warning");
$('#AlertMessage #modalAlertHeaderTypeClass').attr("class", "modal-header alert-warning");
}
$('#AlertMessage #btnAlertOk').attr("onclick", method);
$('#AlertMessage').modal('show');
}
Bước 2: Trên response.result ajax của bạn == gọi đúng với chức năng AlertMessageOk. Tôi đã chuyển tên phương thức để tải lại trang.
chức năng buttonActivate_onClick (StoreID) {
$.ajax({
type: "POST",
url: "/configuration/activateStore",
timeout: 180000,
data: { StoreID: storeID },
success: function (response) {
if (response.result == true) {
AlertMessageOk("Store configuration for Store ID " + storeID + " is successfully activated.", "success", "reloadPage();");
}
},
error: function (xhr, textstatus) {
AlertMessage("Error: " + xhr.statusText + " [" + xhr.status + "]", "error");
}
});
$('#wait_load').css("display", "none");
}
function reloadPage() {
location.reload();
}
Nguồn
2016-04-28 13:13:16
Hãy xem xét rằng khi bạn đang trang được nạp lại, nó sẽ không tự động nhớ trạng thái của trang trước. Khi trang của bạn tải lại tất cả những gì nó sẽ làm là liên kết sự kiện nhấp chuột và không làm gì cho đến khi ai đó nhấp vào nút của bạn. –
Khi bạn tải lại, bạn đang làm mới toàn bộ trang, nó sẽ không có gọi lại –
tôi đã cập nhật câu trả lời của tôi theo cách chính xác hơn – suhailvs