Answer the question
In order to leave comments, you need to log in
Why is the registration form on the site not working?
Hello, the ajax form on the site does not work, please help me figure it out.
Page with a form .
The following files are used for the form to work:
1) /js/common.js
2) /mail.php
other sites on the same server use the same form, everything works. and this site does not work
1)
$(document).ready(function () {
$("#form").submit(function () {
$.ajax({
type: "POST",
url: "/mail.php",
data: $(this).serialize()
}).done(function () {
$(this).find("input").val("");
alert("Вы записаны!");
$("#form").trigger("reset");
});
return false;
});
});
<?php
$recepient = "почта@почта.ru";
$sitename = "Запись к врачу";
$name = trim($_POST["name1"]);
$name = trim($_POST["name2"]);
$phone = trim($_POST["phone"]);
$phone = trim($_POST["data"]);
$phone = trim($_POST["time"]);
$message = "Имя: $name \nТелефон: $phone \nДата: $data \nДата: $time \nСообщение: $text";
$pagetitle = "Письмо \"$sitename\"";
mail($recepient, $pagetitle, $message, "Content-type: text/plain; charset=\"utf-8\"\n From: $recepient");
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question