jpierce42

Access-Control-Allow-Origin header error from sample chart in Chrome

Recommended Posts

I'm in the process of upgrading from FusionCharts 3.2.1 to XT, and I'm currently trying to  create the sample chart in the 'Rendering Javascript Charts' section of this page:  http://docs.fusioncharts.com/charts/contents/Introduction/Upgrading32.html

 

In Firefox & Safari the chart renders correctly.  But in Chrome, the chart says 'No data to display' and I see this error in the console:

 

OPTIONS file://localhost/Users/jenpi/Code/learningfusioncharts/myfirstchart/Data.xml No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. FusionCharts.js:40

XMLHttpRequest cannot load file://localhost/Users/jenpi/Code/learningfusioncharts/myfirstchart/Data.xml. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. weekly-sales.html:1

 

Any idea why this is happening or how to fix it?  Thanks!

Share this post


Link to post
Share on other sites

Hi,

 

It seems that you are using "setXMLUrl" or "setJSONUrl" method to provide data to chart.  Many browsers restrict JavaScript from accessing local file system owing to security reasons. The JavaScript charts, when running locally, will not be able to access data provided as a URL. If you run the files from a server, it will run absolutely fine, though. When running locally, however, if you provide the data as string (using the Data String method), it works fine.  For information on this, you may refer the documentation link : http://docs.fusioncharts.com/charts/contents/index.html?FirstChart/UsingPureJS.html

 

Hence, please try running the sample from a server and check it on Chrome browser.  

 

Awaiting your feedback.

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