我的ajax代码是:
$.ajax({
type: "post",
dataType: "json",
url: "contact.php",
data: $("form").serialize(),
success: function(data) {
if(data.nameValidate == true && data.emailValidate == true && data.messageValidate == true) {
$("form").fadeOut("fast", function() {
$("#contact").append('<p class="sent">' + data.success + '</p>').fadeIn("slow");
});
};
}
});
我必须在 mail.php 的 echo 部分添加什么才能在 HTML 中给出成功消息。PHP 正在发送邮件,但没有向 ajax 发送成功消息。
我试图在这里放一些东西,但没有任何效果。我写了一些 html 代码,echo "<p>.....</p";
但它显示在一个空白页面中。
<?php
$isim=$_POST['name'];
$email=$_POST['email'];
$konu=$_POST['subject'];
$mesaj=$_POST['comments'];
$telefon=$_POST['phone'];
require_once("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "mail.website.com";
$mail->SMTPAuth = true;
$mail->Username = "iletisim@website.com";
$mail->Password = "*******";
$mail->From = "iletisim@website.com";
$mail->Port = 587;
$mail->FromName = " Iletisim Formu";
$mail->AddAddress("example@website","example@website.com");
$mail->Subject = "'".$isim."' adli kisiden mesajiniz var.";
$mail->IsHTML(true);
$mail->Body = 'Isim: '.$isim.
"<br/><br/>"."e-Mail: ".$email.
"<br/><br/>"."Telefon: ".$telefon.
"<br/><br/>"."Konu: ".$konu.
"<br/><br/>"."Mesaj: ".$mesaj;
if($mail->Send())
{
// I try to put something here but nothing is working. I Write some html codes like echo "<p>.....</p"; but it showed them in a blank page.
} else {
echo '<font color="#F62217"><b>Bir Hata Oluştu. Lütfen Telefonla Ulasmayı Deneyiniz.</b></font>';
}
?>