Is it possible to set the charset in an ajax request?

0

I have a problem with the characters. I basically open txt files (with an accent) through ajax, but I'm having trouble with the accents. I want to know if there is an ajax way to open the txt file with accents.

<script charset="UTF-8" >
    function corpo(titulo, texto) {
      var xhttp = new XMLHttpRequest();
      xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            document.getElementById("titulo").innerHTML = titulo;
            document.getElementById("corpo").innerHTML = this.responseText;
        }
      };
      xhttp.open("GET", 'arquivos/'+texto, true);
      xhttp.send();
    }
</script>
    
asked by anonymous 26.11.2018 / 03:42

1 answer

-1

You must save the text file in utf-8 format. Open the file using Notepad, click "save as ..." and next to the "Save" button change to utf-8

    
26.11.2018 / 18:45