Skip to content

Instantly share code, notes, and snippets.

@fnnzzz
Created March 24, 2015 02:32
Show Gist options
  • Save fnnzzz/f286c7b5055af2432cc5 to your computer and use it in GitHub Desktop.
Save fnnzzz/f286c7b5055af2432cc5 to your computer and use it in GitHub Desktop.
sendmail ajax
<?php
$recepient = "agragregra@ya.ru";
$sitename = "УЧЕБНЫЙ АДАПТИВНЫЙ САЙТ №1";
$name = trim($_GET["name"]);
$phone = trim($_GET["phone"]);
$pagetitle = "Новая заявка с сайта \"$sitename\"";
$message = "Имя: $name \nТелефон: $phone";
mail($recepient, $pagetitle, $message, "Content-type: text/plain; charset=\"utf-8\"\n From: $recepient");
?>
//Аякс отправка форм
//Документация: http://api.jquery.com/jquery.ajax/
$("#callback").submit(function() {
$.ajax({
type: "GET",
url: "mail.php",
data: $("#callback").serialize()
}).done(function() {
alert("Спасибо за заявку!");
setTimeout(function() {
$.fancybox.close();
}, 1000);
});
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment