OverrideMimeType alternative for IE

This is a question that never has the right answer, I searched the network many times and I could not find a solution.

xhr.open("GET", fullurl, true); if(xhr.overrideMimeType) xhr.overrideMimeType("text/html; charset=ISO-8859-1"); xhr.send(null); xhr.onreadystatechange = function(){ if(xhr.readyState == 4){ if(xhr.status == 200) alert(xhr.responseText); 

It works for firefox, chrome. My answer: Text will return char as Réunion, which will appear as weird characters.

I tried many methods, such as encoding and decoding, setting a header in the response file, which does not work. I have no ideas. Please help someone.


 **SOLUTION** 

In your main file, make sure you set your content type and encoding.

 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 

On the page loaded on AJAX, make sure you have it at the top.

 header('Content-Type: text/html; charset=iso-8859-1'); 

The problem is solved, your lucky man. it is no longer needed.

 if(xhr.overrideMimeType) xhr.overrideMimeType("text/html; charset=ISO-8859-1"); 
+3
javascript ajax php
source share
2 answers

You do not need anything like overrideMimeType. Just make sure the encodings of your main and loaded AJAX pages are correct (preferably UTF-8 for both). Most likely, you forgot the meta tag declaring the encoding.

+1
source share

I can’t change the encoding using the meta tag and access the server. In IE, I turn to responseBody to create a responseText with the correct characters. Here is my answer:

fooobar.com/questions/81473 / ...

0
source share

All Articles