简体   繁体   English

IE无法读取JSON文件

[英]IE can't read JSON file

I'm trying to load a json file dynamically. 我正在尝试动态加载json文件。 It's 2MB zipped. 压缩了2MB。 When I look at it through most browsers (including IE) at radioladio.com/data/1.json , the json file is automatically unzipped and displayed as the expected text. 当我通过radioladio.com/data/1.json上的大多数浏览器(包括IE)查看它时 ,json文件会自动解压缩并显示为预期的文本。 However, when I try to load it and read it dynamically ( radioladio.com/radioplayer ) in IE, it says there is an invalid character. 但是,当我尝试加载它并在IE中动态读取它( radioladio.com/radioplayer )时,它说有一个无效字符。 I have a feeling this may be something to do with encoding but I'm not too knowledgeable about this sort of thing. 我觉得这可能与编码有关,但是我对这种事情不太了解。 It seems IE may think that it is HTML not json? 似乎IE可能认为它是HTML而不是json?

Try using jQuery's $.get , specifying dataType: "json" or use shorthand: $.getJSON . 尝试使用jQuery的$.get ,指定dataType: "json"或使用简写: $.getJSON I think that you're not specifically saying it's a json datatype so IE takes a default of html. 我认为您不是特别在说这是json数据类型,因此IE会使用html的默认值。 I might be wrong, let me know if that works! 我可能是错的,让我知道是否可行!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM