Handling file access

If you opened the index.html file in Chrome directly, instead of serving it on a web server, you'll notice we've encountered an error. Check your developer console:

The issue here is that web browsers are not supposed to make AJAX requests to files on your computer. If they could, this would be a huge security flaw because any website could access files on your computer. Let's create a basic file server. To do this, you'll need to installNode.js (https://nodejs.org/en/). Once that's done, open your computer's Terminal:

  • For Mac: command + Space, and then type terminal and hit Enter.
  • For Windows: click Start, type cmd

Get D3.js Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.