如何使用ajax加载图形

时间:2015-02-23 13:35:16

标签: javascript php jquery ajax

我得到了这个脚本,我单击一个按钮并显示图形,但它显示奇怪的符号 enter image description here

这是我的代码

anothertestmustdel.php

<input id='submit-button' type = 'button' value='simulate' id='submit' class='but1' />
<div id='randomNum10'>0</div>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="ajax.js"></script>
<script>
var submitEvent = document.getElementById("submit-button").onclick = function()
{
        hello6(HTTP);
}
</script>

ajax.js

function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  return xmlhttp;
}

  var HTTP = loadXMLDoc();

  function hello6(){

    var url = "testmustdel.php";


    HTTP.onreadystatechange=function()
    {
        if (HTTP.readyState==4 && HTTP.status==200)
        {
            document.getElementById("randomNum10").innerHTML=HTTP.responseText;
        }
    };

    HTTP.open("POST", url ,true);
    HTTP.send();
}

testmustdel.php

<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');

// Some data
$ydata = array(11,3,8,12,5,1,9,13,5,7);

// Create the graph. These two calls are always required
$graph = new Graph(350,250);
$graph->SetScale('textlin');

// Create the linear plot
$lineplot=new LinePlot($ydata);
$lineplot->SetColor('blue');

// Add the plot to the graph
$graph->Add($lineplot);

// Display the graph
$graph->Stroke();
?>

我是否必须使用不同类型的ajax来加载图形,或者只是我的代码是错误的,我只是不知道这里发生了什么。

0 个答案:

没有答案