您好我不知道如何通过 innerhtml 将完整的数据返回给对象 xmlhttprequest 的 responsetext,即无需解析。在清单 1 中,它可以工作。但是当我使用如下所示的清单 2 从 php 发送文本时,它不起作用。清单 3 显示了 php 脚本。输出是我看到返回是文本,而不是由 dygraph 函数处理提前谢谢。
Listing1:-
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
z = new Dygraph(document.getElementById("showrealchart"),
"Batch,S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,\n" +
"1, 3.65, 5.00, 4.53, 5.01, 10.50, 0.03, 9.05, 5.05, 5.22, 6.23\n"+
"7, 3.65, 5.03, 4.50, 5.02, 9.50, 0.05, 9.15, 5.55, 5.20, 6.23\n"+
"8, 3.67, 5.00, 4.53, 4.99, 9.00, 0.04, 9.30, 5.10, 2.30, 6.22\n"+
"12, 3.65, 5.04, 4.53, 4.99, 10.05, 0.35, 9.00, 5.23, 5.20, 6.21\n"+
"16, 3.66, 5.00, 4.50, 4.98, 10.50, 1.01, 9.01, 5.20, 5.10, 6.24\n"+
"18, 3.65, 5.02, 4.70, 5.00, 9.80, 0.45, 9.14, 5.63, 5.15, 6.23\n");
}
}
现在我想以确切的形式返回数据。
Listing 2:-
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
z = new Dygraph
document.getElementById("showrealchart").innerHTML=xmlhttp.responseText;
和 PHP 脚本。
Listing 3;-
<?php
print '"Batch,S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,\n" +
"1, 3.65, 5.00, 4.53, 5.01, 10.50, 0.03, 9.05, 5.05, 5.22, 6.23\n"+
"7, 3.65, 5.03, 4.50, 5.02, 9.50, 0.05, 9.15, 5.55, 5.20, 6.23\n"+
"8, 3.67, 5.00, 4.53, 4.99, 9.00, 0.04, 9.30, 5.10, 2.30, 6.22\n"+
"12, 3.65, 5.04, 4.53, 4.99, 10.05, 0.35, 9.00, 5.23, 5.20, 6.21\n"+
"16, 3.66, 5.00, 4.50, 4.98, 10.50, 1.01, 9.01, 5.20, 5.10, 6.24\n"+
"18, 3.65, 5.02, 4.70, 5.00, 9.80, 0.45, 9.14, 5.63, 5.15, 6.23\n";';
?>