andreanovenove
andreanovenove

Reputation: 11

Reading Csv File with Javascript

I have a problem when I read a csv file from javascript with d3 Library. The problem is that:

Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load

this is the code that I execute:

<!DOCTYPE html>
<html>
<meta charset="utf-8">
<body>
<script src="http://d3js.org/d3.v3.js"></script>
<script>
d3.csv("file:///C:/Users/xxxx/Desktop/Nuova/food.csv", function(data) {
console.log(data);
});
</script>
</body>
</html>

Upvotes: 0

Views: 1154

Answers (1)

Steve
Steve

Reputation: 276

You need to be running this on a local server

Are you running the request on a local server? You can only do http requests when you're using a server. Not, for example just opening the file in a browser.

edit: As in, you need to be running a local server. I suggest WAMP if on windows or perhaps using a IDE like webstorm from jetbrains.

This is your issue, you need to be running it on a local server.

Upvotes: 1

Related Questions