我需要通过电子邮件发送jQuizzy结果的帮助 [英] I need help sending jQuizzy results Via email
问题描述
我希望通过电子邮件从jQuery测验"jQuizzy"发送结果.
I am looking to send the results from the jQuery quiz "jQuizzy," via email.
这是将POST发送到名为send.php的文件的代码
This is the code that is sending the POST to file named send.php
if (config.sendResultsURL !== null)
{
console.log("OH HAI");
var collate =[];
for (r=0;r<userAnswers.length;r++)
{
collate.push('{questionNumber:"'+parseInt(r+1)+'", UserAnswer:"'+userAnswers[r]+'"}');
}
$.ajax({
type: 'POST',
url: "send.php",
data: '[' + collate.join(",") + ']',
complete: function () {console.log("OH HAI");}
});
}
这是发送电子邮件的简单PHP代码.
and here is the simple PHP code to send the email.
<?php
$to = "example@example.com";
$subject = "jQuizzy!";
$jsonStr = $_POST["ajax"];
$json = json_decode($jsonStr);
$body = "$json";
mail($to, $subject, $body);
?>
抱歉,问题是我将结果发布到send.php页面,因为电子邮件正在通过,但电子邮件是普通/空的.
Sorry the issue is that I the results are being posted to the send.php page because the email is going through, but the email is plain/empty.
我什至没有考虑检查我发现我的服务器没有任何设置的php错误日志,但是在设置它们之后,似乎在php方面没有任何错误事情.
EDIT 2: I didn't even think about checking the php-error logs to which I found out my server didn't have any set up, but after setting them up it seems there are no errors on the php side of things.
推荐答案
尝试将数据作为对象发送.
Try sending the data as an object.
data: {
ajax: '[' + collate.join(",") + ']'
},
这篇关于我需要通过电子邮件发送jQuizzy结果的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!