Eran Meir
Eran Meir

Reputation: 133

trying to use getJSoN and keep getting an error

I am trying to figure up something very simple, I am trying to load a json file(users.json) data and keep getting an error:

The file location:
the file location

The error:
the error

The path is wrong?

Upvotes: 0

Views: 37

Answers (1)

Latheesan
Latheesan

Reputation: 24116

You have a typo in your syntax.

Replace:

$.getJson("users.json", function() {

With:

$.getJSON("users.json", function(data) {

where data is your json object


P.S. if you get 404 - File not found error when trying to load .json file in a aspx app/page, it means your IIS doesn't know how to serve the .json file.

Therefore, you need to modify the Web.conf file and add the mime type in manually, like this:

<system.webServer>
  <staticContent>
    <mimeMap fileExtension=".json" mimeType="application/json" />
  </staticContent>
</system.webServer>

Upvotes: 1

Related Questions