views:

458

answers:

2

Hi I have a js file that uses ajax to get a XML doc from a php script . The XML file forms the data to draw a Fusion Chart. I know I am getting the XML data ok but FusionCharts will not draw it . I would really appreciate any help , thanks

(FusionCharts.js is included earlier in my script) 

if(XMLHttpRequestObject) {

XMLHttpRequestObject.open("GET", "chart.php?job="+job, true);

XMLHttpRequestObject.onreadystatechange = function() { 
if (XMLHttpRequestObject.readyState == 4 &&  XMLHttpRequestObject.status == 200) { 
var xdoc = XMLHttpRequestObject.responseXML;

     var chart1 = new FusionCharts("Pie3D.swf", "chart1Id", "400", "300", "0", "1"); 
 chart1.setDataXML(xdoc);
     chart1.render("chart1div");

chart.php produces this XML data

<chart caption='ADI Chart Test ' >
  <set label='Driver' value='12.25' />
  <set label='Other Staff' value='223.21' />
  <set label='Equipment' value='0.00' />
  <set label='Additional Items' value='0.00' />
  <set label='Vehicle Fuel' value='0.00' />
  <set label='Accomodation' value='0.00' />
  <set label='Generator Fuel' value='0.00' />
</chart>
A: 

Hello,

It looks as though that you have a 'chart1div', even though it i.e. the Div is not defined. For this, you would need to define a Div.

Also, try using responseText in place of responseXML. Here, the former returns a string while the latter returns a XML document object.

Example: var xdoc = XMLHttpRequestObject.responseText;

:)

Pablo
A: 

Does the "Pie3D.swf" live in the same root directory that you're working from?

Robert Williams