Krok 1: Wpisz swoją funkcję wyskakujące okienko z przyciskiem OK (stworzyłem sparametryzowaną funkcję, która przyjmuje komunikat, typ alarmu, nazwę metody
funkcja AlertMessageOk (str, alertType, metoda)
{
$('#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');
}
Krok 2: Na ajax response.result == true wywołanie funkcji AlertMessageOk. Przekazałem nazwę metody, aby odświeżyć stronę.
funkcja 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();
}
Uważają, że kiedy jesteś strona jest przeładowana, nie będzie automatycznie zapamiętać stan poprzedniej stronie. Kiedy twoja strona przeładuje wszystko, co zrobisz, wiąże wydarzenie kliknięciem i nic nie robi, dopóki ktoś nie kliknie Twojego przycisku. –
Po przeładowaniu odświeżasz całą stronę, nie będziesz mieć oddzwonienia –
Poprawiłem moją odpowiedź w poprawniejszy sposób – suhailvs