Показать сообщение отдельно
  #1 (permalink)  
Старый 11.07.2021, 21:23
Новичок на форуме
Отправить личное сообщение для Warwar Посмотреть профиль Найти все сообщения от Warwar
 
Регистрация: 11.07.2021
Сообщений: 3

Не закрывается модальное окно.
Здравствуйте! Помогите решить проблему с модальным окном. После отправки сообщения оно появляется (так и нужно) но при нажатии на кнопку(и) закрыть оно не пропадает. В консоли ошибка:

"VM21794:1 Uncaught TypeError: alert_close is not a function
at HTMLDivElement.onclick (VM21794:1)"
alert_close(undefined);return false (Uncaught TypeError: alert_close is not a function)

Скрипт:
$(document).ready(function() {

	$("#form").submit(function() {
		$.ajax({
			type: "POST",
			url: "rest.php",
			data: $(this).serialize()
		})
        .done(function() {
			function alert(content,afterFunction){
$('<div class="alertm_overlay"></div>').appendTo('body');
$('<div class="alertm_all"><a href="#" onclick="alert_close('+afterFunction+'); return false" class="alertm_close">x</a><div class="alertm_wrapper">'+content+'</div><div class="alertm_but" onclick="alert_close('+afterFunction+'); return false">ОК</div></div>').appendTo('body');
$(".alertm_overlay, .alertm_all").fadeIn("slow");
$('.alertm_all').css('margin-top', (-1)*($('.alertm_all').height())+'px');
}
function alert_close(afterFunctionClouse){
$(".alertm_overlay, .alertm_all").remove();
afterFunctionClouse;
}

$(document).ready(function(){
alert('СПАСИБО');
}); 
			
		});
		return false;

    });
	
});

Последний раз редактировалось Warwar, 12.07.2021 в 09:19. Причина: Оформил JS
Ответить с цитированием