0

jQuery getJSON 中的回调函数在 Internet Explorer 9 中永远不会被调用,尽管请求的文件已成功加载(我已在“网络”选项卡中检查过)。

var user = 1;

$.ajaxSetup ({
    cache: false
});

var fileUrl = "/path/to/file.php";

var fetchQuestions = function(kanji)
{    
    alert('this fires');
    $.getJSON(
        fileUrl,
        {action: "get-q", kanji: kanji, user: user},
        function(json)
        {
            alert('this does not fire');
            questions = json;
            currentItem = json.info.kanji;
            showStart(json.info);
        }
    );
};
  • 返回的数据是有效的 json
  • 它在所有其他浏览器中都能正常工作
  • 请求的文件确实加载了 200 OK 和 Content-Type application/json
  • 文件中的任何地方都没有 console.log() 调用
  • 控制台中没有错误(在 IE9 或任何其他浏览器中)

有任何想法吗?

这是返回的 JSON:

{"info": {
                "kanji": "線",
                "meanings": "line",
                "desc": "",
                "words": [{"audio":"/jp/files/audio/words/線_せん","kanji":"線","en":"line","jp":"せん"},{"audio":"/jp/files/audio/words/地平線_ちへいせん","kanji":"地平線","en":"horizon","jp":"ちへいせん"},{"audio":"","kanji":"内線","en":"phone extension, indoor wiring, inner line","jp":"ないせん"},{"audio":"","kanji":"直線","en":"straight line","jp":"ちょくせん"},{"audio":"","kanji":"脱線","en":"derailment, digression","jp":"だっせん"},{"audio":"","kanji":"線路","en":"line, track, roadbed","jp":"せんろ"},{"audio":"","kanji":"水平線","en":"horizon","jp":"すいへいせん"},{"audio":"","kanji":"新幹線","en":"shinkansen","jp":"しん・かん・せん"}]
            },
"spots": [{"kanji":"\u5c71","rand_ind":"32"},{"kanji":"\u68ee","rand_ind":"47"},{"kanji":"\u5225","rand_ind":"76"},{"kanji":"\u98ef","rand_ind":"127"},{"kanji":"\u98f2","rand_ind":"175"},{"kanji":"\u9b5a","rand_ind":"203"},{"kanji":"\u5354","rand_ind":"252"},{"kanji":"\u9752","rand_ind":"265"},{"kanji":"\u9032","rand_ind":"302"},{"kanji":"\u805e","rand_ind":"310"},{"kanji":"\u8a08","rand_ind":"311"},{"kanji":"\u4ea4","rand_ind":"362"},{"kanji":"\u4f1a","rand_ind":"367"},{"kanji":"\u53d7","rand_ind":"404"},{"kanji":"\u5973","rand_ind":"463"},{"kanji":"\u90e8","rand_ind":"469"},{"kanji":"\u4e16","rand_ind":"476"}],
"known": "月,後,前,生,?"}
4

1 回答 1

0

json_encode 对返回的 JSON 的“已知”部分进行编码解决了这个问题!看起来 IE 对 unicode 字符有一些问题。

于 2012-08-02T12:08:55.760 回答