JSON File Extension

Viewed 45537

I've been saving all my json files with .txt extension and they worked with jquery ajax calls.

When I change the extension to .json and in my jquery ajax call -- jQuery.ajax() -- I specify

  • dataType: "json",
  • contentType: "application/json; charset=utf-8",

the files no longer work. Why so?

Shouldn't all json files have an extension .json? I'm using IIS server.

JSON

{ "rows": [ 
  {"row":[ 
    {"cells": [ 
      {"data": "Edit"}, 
      {"data": "030194"} 
    ]} 
  ]}, 
  {"row":[ 
    {"cells": [ 
      {"data": "Add"}, 
      {"data": "030194"} 
    ]} 
  ]}  
]}

jQuery

jQuery.ajax ({ 
  type: "GET", 
  url: "localhost/ABC.json", 
  dataType: "json", 
  contentType: "application/json; 
  charset=utf-8", 
  cache: "false", 
  success: function(response){}  
});

Can someone please tell me why extension .json is not working? It works if I change it to .txt

3 Answers
Related