通过Ajax发送到PHP电子邮件的HTML表丢失0值

时间:2015-05-22 23:52:19

标签: php html ajax html-table html-email

我不确定这是ajax还是PHP问题但是...我有一个基本的HTML表,我使用jQuery动态加载一些值,它在前端显示它们都很好,我然后通过ajax发送它与其他一些表:

//activate email option
$("#sendEmail").click(function(){
    var emailadd=prompt("Please enter your email address");
    var data = {
        email: emailadd,
        message: $("#cresult").html(),
        message2: $("#cscores").html(),
        message3: $("#ffc").html()
    };
    $.ajax({
        type: "POST",
        url: "sendEmail.php",
        data: data
    });
});

到基本的PHP电子邮件脚本:

<?php
if($_POST){
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-Type: text/html'; charset=utf-8 . "\r\n";
$to      = $_POST["email"];
$subject = 'Stand Alone Algorithm Results';
$message = $_POST["message2"]. $_POST["message"]. $_POST["message3"];
mail($to, $subject, $message, $headers);
}
?>

这一切都很可爱......除非它在收件箱中到达任何包含值为&#34; 0&#34;的表格单元格。现在是空的吗?

我认为可能有一个Tolkeinesk Ajax妖精吃掉了生活在客户端和服务器之间的黑暗空间!

感谢任何灵感。

作为更新,有问题的HTML表位于message2:$(&#34; #cscores&#34;)。html(),html为:

<div id="cscores">
<H3>Scores</H3>
<table id="scorestable" border="2">

<th>No</th><th>Item Description</th><th>Score</th><th></th>
<tr><td>1</td><td>Overactive, aggressive, disruptive or agitated behaviour</td><td></td></tr>
<tr><td>2</td><td>Non-accidental self-injury</td><td></td></tr>
<tr><td>3</td><td>Problem drinking or drug taking</td><td></td></tr>
<tr><td>4</td><td>Cognitive Problems</td><td></td></tr>
<tr><td>5</td><td>Physical Illness or disability problems</td><td></td></tr>
<tr><td>6</td><td>Hallucinations and Delusions</td><td></td></tr>
<tr><td>7</td><td>Depressed mood *</td><td></td></tr>
<tr><td>8</td><td>Other mental and behavioural problems *</td><td></td><td></td></tr>
<tr><td>9</td><td>Relationships</td><td></td></tr>
<tr><td>10</td><td>Activities of daily living</td><td></td></tr>
<tr><td>11</td><td>Living conditions</td><td></td></tr>
<tr><td>12</td><td>Occupation and Activities</td><td></td></tr>
<tr><td>13</td><td>Strong Unreasonable Beliefs</td><td></td></tr>

<tr><td>A</td><td>Agitated behaviour/expansive mood</td><td></td></tr>
<tr><td>B</td><td>Repeat Self-Harm</td><td></td></tr>
<tr><td>C</td><td>Safeguarding other children and vulnerable dependant adults</td><td></td></tr>
<tr><td>D</td><td>Engagement</td><td></td></tr>
<tr><td>E</td><td>Vulnerability</td><td></td></tr>
</table>
</div>

我正在通过jquery:

加载带有文本的空td
/add scores to scorestable table for email
var r=1;
$.each( $(".scorebox"), function() { 
var x=(this.innerHTML); 
$("#scorestable tr:eq("+r+") td:eq(2)").text(x);
r++;
});

//add item 8 problem type to scorestable
var prob=$("#probtype").text();
$("#scorestable tr:eq(8) td:eq(3)").html(prob);

顺便提一下,这是一个护理工具,因为我的职业是护理而不是编码,所以永远不要认为我已经正确地介绍了基础知识,并且不要对粗制滥造的编码过于苛刻。

0 个答案:

没有答案