开发者

Asynchronous json javascript query fails with unicode characters on IE only

I'm doing ajax query

$.ajax({
    url: (some url),
    dataType: "json",
    error: function(xhr, textStatus, er开发者_JAVA技巧rorThrown) {
        (error handler)         
    },
    data : requestData,
    success: function(data) {
        (success handler)
    }
});

Works perfectly on Opera/Firefox/Webkit browsers. However when using IE and having requsestData containing some strings with non ascii characters (e.g. ł), error is returned and xhr status is 12031. Note that even replacing url to some existing document does not give 404 status (it does however in Opera etc.), so I think query isn't executed at all.

About mentioned duplicate: unfortunately it did not help me. Tried encodeURIComponent without result (and no wonder, cause jquery automatically does that when object is passed to requestData). Even hardcoded the query (passed as string) but it does not work too.

UPDATE: Query will work with non ascii data if it is cached in IE. That means I can copy prepared XHR url, paste it into another IE tab, then refresh the original page with ajax and receive no error.

UPDATE again: Fixed. What wasn't encoded properly was the referer url given in ajax query. It contained hash with non ascii character (however if cached, worked ok). Thank you for your efforts.


Remember your Ajax call must conform to UTF8 since you are not specifying the charset then it is the default.

That character is not acceptable in UTF8 and you have to encode it yourself. True, some browsers probably do it for you but basically you need to do it yourself in IE.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜