我正在尝试将测试分数传递给 php 脚本,然后将结果通过电子邮件发送给用户。我将分数输出到控制台,效果很好(显示我的百分比),但是当发送电子邮件而不是分数时,它显示为 NaN。
这是我的代码...
score = roundReloaded(trueCount / questionLength * 100, 2);
$.ajax({
type: 'POST',
url: config.sendResultsURL,
data: { q:score },
complete: function () {console.log("Sending complete. The score was "+ score + "%");}
});
还有我的 emailData.php 文件...
$body = "You scored " . $_POST['q'] . "%";
$to = "someone@test.com";
$email = 'admin@test.com';
$subject = 'Results';
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
// Send the email:
$sendMail = mail($to, $subject, $body, $headers);
有人可以帮助我并告诉我我做错了什么吗?
谢谢