阅读与解析unicode json数据在IE和FF中不起作用 [英] Read & parse unicode json data not work in IE and FF

查看:59
本文介绍了阅读与解析unicode json数据在IE和FF中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从另一个域(CORS)读取json数据文件.此文件包含Unicode数据,例如:

I want to read json data file from another domain (CORS). This file contain Unicode data, Like:

{"id":21,"name":"پرسپولیس تهران"}

我使用了像这样的JQuery Ajax函数:

I used JQuery Ajax function like this:

$.ajax({
    type: "GET",
    cache: false,
    url: SDomain + 'XML/TeamXMLCache/' + filename + '.json',
    dataType: "json",
    contentType: 'application/json; charset=UTF-8',
    success: parseXml,
    error: function (request, status, errorThrown) {
        console.log(request);
        console.log(status);
        console.log(errorThrown);
    }
});

这在Chrome 39中可以正常运行,但在IE11和amp;中无法正常工作FF32.

And this work me fine in Chrome 39 but not working in IE11 & FF32.

在IE中,我收到 parsererror 错误.

In IE I get parsererror error.

有关更多信息:

  • responseText是: {"id":21,"name":〜13〜HD3 * G1'F"}
  • readyState:4
  • statusText:确定"
  • 状态:200

最后我的配置文件是:

<configuration>
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" />
      </customHeaders>
    </httpProtocol>
  </system.webServer>
</configuration>

所以请告诉我为什么?我不是初学者!

So please tell me why? I'm not a beginner!

实际示例是:推荐答案

当我加载

When I loaded http://static.persiangulfcup.org/XML/TeamXMLCache/21-%D9%BE%D8%B1%D8%B3%D9%BE%D9%88%D9%84%DB%8C%D8%B3-%D8%AA%D9%87%D8%B1%D8%A7%D9%86.json?_=1417448329770 with Firefox in a browser window, it displayed the JSON fine but indicated in document info that the encoding is UTF-16LE and not UTF-8 as indicated in your post. Based on that I think you need to make sure the data is correctly UTF-8 encoded or you need to make sure it is served with a content type header indicating the real encoding.

这篇关于阅读与解析unicode json数据在IE和FF中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆