1

I am trying to get my script to load in a JSON file which is located in the root of my website:

$.getJSON( "slides.json", function(json) {
    var slides = json;
    console.log(slides);
}

However, on loading the website I get the following error:

Failed to load resource: the server responded with a status of 404 (Not Found)

So I tried surfing to http://mywebsite/slides.json, and also got a 404. So I tried to change my file extension to slides.txt, and that worked just fine with the surfing, as well as the script reading.

Can somebody explain why my IIS won't distrubute the JSON file as it would a text file?

Thanks :)

Saravana
  • 37,852
  • 18
  • 100
  • 108
Djov
  • 654
  • 1
  • 10
  • 19
  • you changed the extension *on the server* or just in your javascript? – Jamiec May 24 '17 at 09:06
  • 1
    Did you try to take a look to this link? Unfortunately I think that the issue should be with IIS not JS, so you may think to add also IIS as tag at your question https://stackoverflow.com/questions/332988/get-iis6-to-serve-json-files-inc-post-get – quirimmo May 24 '17 at 09:07
  • 1
    Unfortunately by default IIS doesn't serve JSON. Try these steps: - Open IIS Manager - Right click on `MIME` and choose `open feature` - Add a new action (top right with `Add...`) - Enter `JSON` for the extension and `application/json` for the MIME type. Hope this helps! – ivanasetiawan May 24 '17 at 09:14
  • Thanks guys, indeed the question was already answered. I just didn't know what to look for. :) – Djov May 24 '17 at 11:05

1 Answers1

1

Unfortunately by default IIS doesn't serve JSON. Try these steps: - Open IIS Manager - Right click on MIME and choose open feature - Add a new action (top right with Add...) - Enter JSON for the extension and application/json for the MIME type.

Hope this helps!

ivanasetiawan
  • 879
  • 1
  • 10
  • 26