Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript D3.js Data Binding with D3.js Data Binding

Tam Dao
Tam Dao
316 Points

My browser cannot load the climate-data.csv due to cross origin issue.

I'm not using workspace. I downloaded the project files and open it on my text editor. I got this error when I made the d3.csv request in dataBinding.html:

XMLHttpRequest cannot load file://Users//Documents//D3js-master/Stage2/examples/climate_data.csv. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

1 Answer

Marco Flores
Marco Flores
7,971 Points

Happened the same to me,

You should run the html examples within a web server, because d3.json(), d3.csv(), etc perform ajax request internally to get data.

One way to setup a simple http server is with python 3.

I downloaded the project files and place it in C:\D3js-HustonHedinger-master

Then with cmd, and located in that directory, start a web server:

python -m http.server 8000 --bind

Then browse http://127.0.01:8000/Stage2/examples/dataBinding.html