0
votes

I am trying to load a text file in HTML page. The content of the text file is in German and I see � this symbol for German characters ä,ö,ü. I have used <meta charset="UTF-8"> in the head tag of html page and also tried saving the text file in ANSI and UTF-8 but didn't work. Here is my code:

$.ajax({
    type: "GET",
    url: lnk3,
    crossDomain: true,
    dataType:"text",
    processData: false,
    xhrFields: {
        withCredentials: true
    },
    error: function(XMLHttpRequest, textStatus, errorThrown) { 
          console.log("Ajax call failed");
    },
    success: function(jsonData) {
        $("#description").html(jsonData);
    }

 });

and the HTML Code

<html>
<head>
<meta charset="UTF-8">  
<script src="jquery-2.1.3.min.js"></script>
<script src="base64.js"></script>  

</head>
<body>   
   <div id="demo3">
        <button class="bck" onclick="loadFile()">Back</button>

    </div>

        <div id="description">
        </div>

</body>   
</html>

Text file is loaded in div tag with id="description" and the text file that I want to load is stored on sharepoint

Please help me to solve this issue

1
@Shardul Sane hi it's due to the special characters(german lang) in your text you might not have your html as "Encoding with UTF-8" just try your once again with encoding and it will workHimesh Aadeshara
should work with text file encoded in utf-8Kaiido
This might solve the problem. cybervaldez.com/…sanjeev shetty

1 Answers

1
votes

Make sure that your browser has set the encoding to UTF-8. In chrome you can check this by customize(right corner)->more tools->encoding->UTF-8. If it is not utf-8, then there is something wrong with the meta tag.