JSON File Extension

后端 未结 3 1316
轮回少年
轮回少年 2021-02-15 17:17

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 --

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-15 17:28

    dataType: "json" is not to specify the type of a file is to specify the kind of data that the server will return. From the server side, for example if you are using php, you have to return the json string using the function "json_encode" so it can be accepted by dataType: "json".

提交回复
热议问题