I was trying to load a JSON file located within my Visual Studio project using $.getJSON(), however the code below doesn't work as expected.
$.getJSON('/Assets/misc/employee.json', function (data) { alert('processing!'); }) .done(function (r) { alert(r.message); }) .fail(function (s) { alert('oops the file is missing!'); });
I remember the solution in one of my ASP.NET project was to set the MimeMap in the web.config inside the system.webServer element. After setting the MimeMap for json files, I can now load local JSON files using $.getJSON().
<system.webServer> <staticContent> <mimeMap fileExtension=".json" mimeType="application/json" /> </staticContent> </system.webServer>
:-)
0 comments:
Post a Comment