1

I created a new TypeScirpt project, added the json file to the solution, changed the 'Copy to Output directory' property to Copy always.

When I F5 the project, the browser complains that it cannot find the resource somedata.json

If I run the python SimpleHTTPServer, load up the same html file, it works.

 <script type="text/javascript">
     d3.json("somedata.json", draw);
 </script>

Thank you.

Doug Finke
  • 6,675
  • 1
  • 31
  • 47
  • You verified that `somedata.json` ended up in the root of the output directory where you expected it to be? If you drag the file from the solution explorer onto your text file, what path does it add? – Bill Oct 15 '12 at 01:47
  • Yes, those all look good. the json file is where it should be. If I run the python http server there, it all works. I'm running Windows 8 with IISExpress – Doug Finke Oct 15 '12 at 02:14

3 Answers3

1

Have you tried using the full path from the root of the site to obtain the somedata.json file?

d3.json("/scripts/somedata.json", draw);

Replace /scripts/ with the correct path in your instance, but start the address with a leading / to make it relative to the root.

Fenton
  • 241,084
  • 71
  • 387
  • 401
  • In Visual Studio I created a folder *data*. d3.json("/data/somedata.json", draw); It didn't work from studio but it did work from python. Weird, I'm missing something simple. – Doug Finke Oct 15 '12 at 21:54
0

This may be related to MIME types that the server used by Visual Studio is allowed to serve. You can define such MIME types at web.config btw if this is an ASP.net project.

Also see this official example in case it helps: http://www.typescriptlang.org/Samples#D3

George Birbilis
  • 2,782
  • 2
  • 33
  • 35
-1

Have you tried to run the project using ASP.NET Development Server?

Gamer
  • 19
  • 2