Loko

setDataUrl with a server url shows "Error in loading data"

Recommended Posts

Hello

 

 

 

I'm a new user to FusionCharts, and trying to adapt the samples to my needs.

 

 

 

This is my HTML/JS code :

 

 

 


var chart = new FusionCharts("../Charts/MSLine.swf", "ChartId", "600", "350", "0", "1"); 

chart.setDataURL('/portal/pls/portal/gfc_dev.deplacements.p_test?');

chart.render("chartdiv");

 

 

 

and my server returns : --> see attachement as the [ code ] [ /code] tags does not seem to work.

 

 

 

And I get the "Error in loading data" message.

 

 

 

It works fine if I put the data in a javascript variable and pass it to setDataXML().

 

 

 

Could you explain me what's wrong ?

 

 

 

Regards

 

Loko

data.txt

Edited by Guest

Share this post


Link to post
Share on other sites

Hello Loko,

Welcome to the forum. :)

In the line--> chart.setDataURL('/portal/pls/portal/gfc_dev.deplacements.p_test?');

The path needs to be set to the XML file.

Could you please rectify this and try again?

Share this post


Link to post
Share on other sites

There is no xml file. This url launches a script on the server that then returns the content of my attached file as en HTTP response.

 

 

 

Many data servers work like this, to return some XML or JSON data on the fly, without having to manage some boring and useless files.

Edited by Guest

Share this post


Link to post
Share on other sites

Okay. Could you please ensure that the script sends content=text/xml and try again? Your current script seems to be sending content=text/html .

I hope this helps! 

Share this post


Link to post
Share on other sites

Yes, you're right, I got use to send some JSON data and in that case, text content is ok.

 

 

 

I guess this would work with the content=text/xml flag, but unfortunatly I can't set it within my server script :-(

 

 

 

Anyway I can workaround this : I will get the xml data via an ajax call then store it in a javascript var then use setDataXML.

 

 

 

Many thanks for your help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now