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 :)
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!