Answer the question
In order to leave comments, you need to log in
How to attach a message?
Hello! There is a form for sending a message from the site to the mail. I want to fasten a message about the successful sending and so that after sending the page is not updated. Help implement.
<script type="text/javascript">
$(document).ready(function(){
$("#form").submit(function(){
var form_data = $(this).serialize(); //собераем все данные из формы
$.ajax({
type: "POST", //Метод отправки
url: "send.php", //путь до php фаила отправителя
data: form_data,
success: function(){
//код в этом блоке выполняется при успешной отправке сообщения
alert("Ваше сообщение отпрвлено!");
}
});
});
});
</script>
<form id="form">
<div class="row 50%">
<div class="6u 12u(mobile)"><input type="text" name="name" placeholder="ФИО" required="required"/></div>
<div class="6u 12u(mobile)"><input type="text" name="email" placeholder="Email" required="required"/></div>
<div class="6u 12u(mobile)"><input type="text" name="tel" placeholder="Телефон" required="required"/></div>
<div class="6u 12u(mobile)"><input type="text" name="skype" placeholder="Skype" required="required"/></div>
</div>
<div class="row 50%">
<div class="12u"><textarea name="message" placeholder="Сообщение" rows="6" required="required"></textarea></div>
</div>
<div class="row">
<div class="12u">
<ul class="actions">
<li><input type="submit" value="Записаться" /></li>
</ul>
</div>
</div>
</form>
Answer the question
In order to leave comments, you need to log in
$("#form").submit(function(event){
event.preventDefault(); //вот эту строку добавь
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question