0

I'm trying to load a CSV file using D3.csv(MY_EXTERNAL_URL) function,but it doesn't load. Seems that it doesn't find the file itself.

Here is my code.

d3.csv ("http://localhost:8080/SOME_LINK", function (tuples) {
console.log(tuples);
//tuples is empty
});

However, when I copy/paste MY_EXTERNAL_URL on browser it downloads the CSV file instantly.

Any help would be much appreciated.

I'm thinking maybe I miss some headers?

Thanks in advance.

4

2 回答 2

2

“外部”是指来自另一个域/网站?

我猜你遇到了浏览器的同源策略。您不能向另一个域发出 ajax 请求,这是您的浏览器禁止的。

在此处阅读更多信息: http ://en.wikipedia.org/wiki/Same_origin_policy

于 2013-07-16T18:25:34.230 回答
0

您确定您使用的是 d3.csv 函数吗?因为您的代码说您正在使用 d3.json 函数。如果这不起作用,您可能需要将“.csv”结尾添加到文件中,然后将其打开为 SOME_LINK.csv

于 2013-07-16T18:19:27.620 回答