How do I open a json file using javascript d3?

后端 未结 3 1760
醉酒成梦
醉酒成梦 2020-12-11 22:36

I\'m trying to extract elements from a JSON file using javascript, however I\'m getting an error saying it can not load the JSON file.

This is what my code looks lik

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-11 23:17

    d3.json is meant to load data through HTTP. As @Quentin said, you can set up a local server to serve the data over HTTP.

    For development like this I use firefox, it seems to be more permissive when it comes to local cross origin requests than chrome. Alternatively you can use http://tributary.io/

    Example with your code: http://tributary.io/inlet/5776228

提交回复
热议问题