【发布时间】:2016-04-01 01:24:24
【问题描述】:
我正在尝试调用 jQuery.getJSON,但它没有在 Internet Explorer 中返回任何数据。以下代码适用于所有浏览器并返回除 IE 之外的数据。
jQuery.getJSON("/samplejsonfile.json",function(data){
console.log('inside'); //For IE the control never reaches here
camData = data;
})
json 文件包含特殊的 unicode 字符,这就是 getJSON 方法在 IE 中不起作用的原因。下面是我的示例 JSON 文件:
{"id":74112,"title":"Flø","cameratype":"0"}
有什么方法可以让这个工作并让 IE 正确返回数据?
【问题讨论】:
-
什么版本的IE? stackoverflow.com/questions/2570757/… 说这在 IE8 中不起作用,但应该在 IE9 中起作用。
-
版本为IE 11。Edge中不存在此问题。
-
Javascript 控制台有错误吗?
-
是的,错误函数返回以下错误。而这个错误是因为 json 中的特殊字符:{description: "Expected '}'", message: "Expected '}'", name: "SyntaxError", number: -2146827279, stack: "SyntaxError... "}
标签: javascript jquery json internet-explorer