代码是这样的。它没有回应。 JavaScript的。 我正在尝试联系表格。
function sendContact() {
var valid;
valid = validateContact();
if(valid) {
jQuery.ajax({
url: "contact.php",
data:'name='+$("#name").val()+'&email='+$("#email").val()+'&subject='+$("#subject").val()+'&content='+$(content).val(),
type: "POST",
success:function(data){
$("#mail-status").html(data);
},
error:function (){}
});
}
}
php文件是
<?php
include_once "config.php";
$name = validate($_POST["name"]);
$email = validate($_POST["email"]);
$message = validate($_POST["message"]);
$subject = validate($_POST["subject"]);
$to = 'myemail@example.com';
$mailHeaders = "From: " . $name . "<" . $email . ">\r\n";
if (mail($to, $subject, $message, $mailHeaders)) {
print "<p class='success'>Contact Mail Sent.</p>";
} else {
print "<p class='Error'>Problem in Sending Mail.</p>";
}
function validate($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}