jQuery/PHP在mousedown链接事件上发送电子邮件
这是我的密码。我无法显示错误消息。只是邮件不被发送。这种方法有什么问题jQuery/PHP在mousedown链接事件上发送电子邮件,php,jquery,sendmail,Php,Jquery,Sendmail,这是我的密码。我无法显示错误消息。只是邮件不被发送。这种方法有什么问题 <a id="target" href="http://www.mylink.wav">mylink</a> <script type="text/javascript"> $(function() { $("#target").mousedown(function() { $.post(
<a id="target" href="http://www.mylink.wav">mylink</a>
<script type="text/javascript">
$(function() {
$("#target").mousedown(function() {
$.post(
"sendemail.php",
{ name: "John" }
);
});
});
</script>
<?php
if($_POST)
{
$mail = "myemail.email.com"
$name = $_POST['name'];
$subject = 'My subject';
$to = "myemail@email.com";
$message = "My message: ".$name."<br />";
$headers = "From: $mail \n";
$headers .= "Reply-To: $mail \n";
$headers .= "MIME-Version: 1.0 \n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1 \n";
}
?>
$(函数(){
$(“#目标”).mousedown(函数(){
美元邮政(
“sendmail.php”,
{姓名:“约翰”}
);
});
});
感谢您提出解决此问题的建议。首先检查您是否确实在jQuery块内调用脚本 其次,您需要包括php
mail()
函数(如果在服务器上启用):
嘿,这是工作!谢谢。我很高兴这有帮助:)!
mail($to, $subject, $message, $headers);