Md. Nahidur Rahman Md. Nahidur Rahman - 1 year ago 95
JSON Question

HTTP Get in AngularJs Could not located the Json file

I have tried several times with the following code to get the json data.

var todoApp = angular.module("todoApp", []);$http) {

$http.get('todo.json').success(function (data) {

model.items = data;

here todo.json file is located on the root of the project....what wrong i am doing?

Answer Source

if you are using visual studio with IIS Express to debug then you will have to add a mime type for the static json file otherwise this debug server wont know how to handle the request for this type of file. you can do by

1.Adding a new web config file in your project (if it dosent exist)
2.Adding this inside the file

      <mimeMap fileExtension=".json" mimeType="text/json" />

under config section / tag. More info about this here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download