📜 ⬆️ ⬇️

AJAX, IE and CP1251

I did something here somehow on an Ajax, transferring data to JSON 'e, the encoding of everything on website is cp1251 . In order not to reinvent the wheel using jQuery .
Everything worked fine until I decided to test everything in IE . IE my seventh version, I haven't checked it in others yet, but in my opinion there’s the same feature.
So, nothing worked without unspecified errors (visible). Having rummaged has found out that jQuery returns parsererror . Having rummaged deeper, I found out that the transport drops out with an access when accessing the responseText field and the responseXML field contains an empty document (which, of course, the data is transmitted by text).
Having worked with a jigsaw and Google for half an hour at random, I found out that:
  1. if the encoding with headers is not utf-8 IE refuses to work absolutely;
    content type application/ajax and application/x-javascript also do not rule.

    In general, in the end he began to issue the header Content-type: text/plain; charset=utf-8 Content-type: text/plain; charset=utf-8 and recode everything in utf-8 (good with iconv it came out in three lines).
    No, I certainly read that IE not friendly with the Windows cp1251 encoding, but I figured it out for now;)
    People! Do not repeat the mistakes of others :)

    UPD


    Hmm, sprinkle my head with ashes. It turned out that everything is pretty well corrected by replacing the cp1251 encoding with windows-1251 :) Thanks for the advice.

')

Source: https://habr.com/ru/post/29265/


All Articles