The problem with sending a message from the form, at the time of loading from another page.

It turns out to send only from the page where the form itself. I tried instead of #form register .send . Alert sends a message about sending, but nothing comes to the mail

 $(document).ready(function(e) { var btnClick = $('.link'); // кнопка, по нажатию которой будет подгружаться форма var btnCls = $('.close'); // кнопка закрытия формы btnClick.click(function() { if($( window ).width() > 768) { // данный метод будет работать только в полной версии сайта $('.send').load('ссылка на форму #form').fadeIn(4000); // подгружаем форму из указанной ссылки и ее контента $('#form').submit(function() { // устанавливаем событие отправки для формы с id=form var form_data = $(this).serialize(); // собираем все данные из формы $.ajax({ type: "POST", url: "post.php", data: form_data, success: function() { alert("Ваше сообщение отпрвлено!"); } }); }); }); } /* function btnClose() { btnCls.click(function() { $('.send').fadeOut(2000); }); } btnClose(); */ }); 

    1 answer 1

    Try through on();

     $(document).ready(function() { var width = $(window).width(); if (width > 768) { $('body').on('click', 'form .link', function(e) { e.preventDefault(); $('.send').load('ссылка на форму .posted'); $('.send').fadeIn(4000); $.ajax({ type: 'POST', url: 'post.php', data: $(this).parent().serialize(), success: function() { alert("Ваше сообщение отпрвлено!"); $('.send').fadeOut(2000) } }); return false; }); } }); 
    • I tried, it does not work, after I send alert () it does not work and nothing comes to the mail. - daydreams
    • @daydreams show your php code - KYRAN