我有以下代码:AJAX:
$.ajax({
url: "mail.php",
type: "POST",
data: {first_name:first_name,last_name:last_name,email: email,telephone:telephone,message:message},
cache: 'false',
dataType: "json",
success: function(response) {
{
if(response.status==1)
alert('Email sent!');
else
alert('Error.')
}
}
});
PHP:
header('Content-type: application/json');
$to="me@example.com";
$message=$_POST['message']."\r\n"."\r\n".$_POST['first_name'].' '.$_POST['last_name']."\r\n".$_POST['telephone'];
$subject="New Message!";
$email=$_POST['email'];
$headers="From:".$email;
$success=mail($to,$subject,$message,$headers);
if($success)
{
$done=array("status"=>true);
echo json_encode($done);
}
else
{
$done=array("status"=>false);
echo json_encode($done);
}
在网络面板中,似乎没有收到响应,类型为“待处理”