Xhr Request Garbles Encoding In Chrome, Works Fine In Safari
The following code POSTs 'it’s' in Chrome, but 'it’s' in Safari. invocation = new XMLHttpRequest() invocation.open('POST', 'https://example.herokuapp.com/content/24/nl/123
Solution 1:
Make sure to set the response header
Content-Type: text/html; charset=UTF-8
also on the https://example.herokuapp.com/content/24/nl/123
target page, not just on the website (the request page). Also check if the encoding of any data source (including the target itself) is in UTF-8.
As far as I have tested, the garbled encoding comes only from the charset incompatibilities on the path
client encoding- client request- server encoding- server data- server response
Note: if your web server runs on PHP, you can use header for response header. If you can not set the header for some reason, use iconv to convert the response from your charset to UTF-8.
Post a Comment for "Xhr Request Garbles Encoding In Chrome, Works Fine In Safari"