Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

404 Error while trying access JSON file using D3 Framework

Hi so i'm in the middle of learning the D3 Framework, but no matter what I do, I can't seem to load my Json file. I'm running the script on a server and the JSON file is in the same directory as the html/d3 file im running it from but it keeps giving me a 404 error when I look at the console.

So Im running it on www.mywebsite.com, and then I have the Json file stored in www.mywebsite.com/mydata.json
Can anyone help me out?

<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> 
</head>
<body>
    <script type="text/javascript">

    d3.json("mydata.json", function(data){ 

        var canvas= d3.select("body").append("svg")
        .attr("width",500)
        .attr("height", 500)

        canvas.selectAll("rect")
            .data(data)
            .enter()
                .append("rect")
                .attr("width", function(d){ return d.age *10;})
                .attr("height", 50)
                .attr("y", function(d ,i){ return i* 50; })
                .attr("fill", "blue");
    });

    </script>
like image 579
mross1080 Avatar asked Jan 09 '14 00:01

mross1080


2 Answers

Take a look at this and this gotchas. Let us know if you succeeded accessing json after that.

like image 112
VividD Avatar answered Sep 23 '22 13:09

VividD


You guys need not change any Formats. Just need to change some settings in Server.Here I am using IIS server so I have tested my files and got same 404 error for JSON Files and I made the following changes and it worked like a Charm. You just follow this If you are using an IIS Server...

Step 1: Open IIS Server and go to MIME Types

enter image description here

Step2: Click Add from right side and add JSON extension and restart the server

enter image description here

like image 25
Gvs Akhil Avatar answered Sep 23 '22 13:09

Gvs Akhil