我正在尝试通过 AJAX POST 将较大的数据集传递给 PHP。我的数据被截断,但我不明白为什么。
var greeting = tinyMCE.get("greeting").getContent();
...
var content = "subject=" +subject+
"&greeting=" +greeting+
"&results=" +results+
"&upcoming=" +upcoming+
"&thisweek=" +thisweek+
"&signoff=" +signoff;
console.log(content); //<--see below for this output
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "scripts/send_email.php", true);
xmlhttp.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xmlhttp.send(content);
发送电子邮件.php
$greeting = $_POST['greeting'];
echo $greeting;
die();
这是我的内容变量的控制台输出(请注意,在您看到格式的地方,控制台输出 HTML 标记,但我不知道如何在此处显示标记。)
> subject=test&greeting=<p class="p1"><strong>Hello all,</strong></p> <p
> class="p2"> </p> <p class="p1"> </p> <p class="p3">This is a
> test. I am just typing some random stuff to verify that all of my data
> is getting passed correctly over to PHP. However, it seems that this
> data is being truncated for reasons that I cannot explain. Why would
> this happen. How can I get all of this data to pass correctly? It
> doesn’t make any sense to me as I am using an AJAX POST call and
> not a GET call, so my data length should not be arbitrarily
> limited.</p>&results=<p><strong><span style="text-decoration:
> underline;">RESULTS</span></strong><br /><br /><br
> /></p>&upcoming=<p><strong><span style="text-decoration:
> underline;">UPCOMING EVENTS</span></strong><br /><br /><br
> /></p>&thisweek=<p><strong><span style="text-decoration:
> underline;">THIS WEEK</span></strong><br /><br /><br
> /></p>&signoff=<p>See you out there.</p>"
但是,我的 php echo 语句只输出这个:
Hello all,
这清楚地截断了我试图忽略的其余数据。为什么?我究竟做错了什么?谢谢!