I am trying to read a json file at localhost. it is not read by the browser.
is this even possible? the json file is kept in my local pc.
$.getJSON("p.json",function(data){
alert("success");
});
chrome gives me a 404 for this. the file is there. http://localhost/myfoldername/p.json
what is it that i am doing wrong? the json file has not been prepared by a server, but i have prepared it my self. the syntax is correct, though.
EDIT: if i shoot to the file in the browser by hitting its url, localhost/myfolder/p.json, it gives me a 404.3 error saying if it is a script file, there should be a MIME handler for it. how to get this working?? – amit 0 secs ago edit
If the server says it is a 404, that means it cannot find it. 99% of the time this means that there is some problem with the request. Some thoughts:
localhost/myfoldername/p.jsondo you get a 404? If so, that means that your path to the file is wrong. Make sure thatmyfoldername/p.jsonis in the appropriate directory on your hard drive (last night I lost a minute or so because I accidentally managed to save something toC:\xampp\phpinstead ofC:\xampp\htdocs).myfoldername? If not, the request will be to the wrong directory. Change “p.json” tomyfoldername/p.jsonor../myfoldername/p.json.Edit
Just noticed your edit. I had not realized that IIS disabled the
.jsonMIME type by default. You can find instructions on how to configure that here.