.load () kills character encoding
I use the following code to download content:
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function(){
jQuery('.content-div').load("all-events.html");
});
</script>
However, the content is loaded without the special characters that I want in UTF-8. It was mentioned somewhere to put this at the beginning of my code:
$html = header('Content-Type: text/html; charset=utf-8');
However, I got this error: 'header not defined'.
Thanks for helping everyone, however I found what the problem was. The problem was that adding headersto the main text file did not change its actual encoding. I wrote this file in notepad and was not able to verify the correct encoding. Then I opened it in Notepad++and set the encoding from this application. Hope this helps others struggling with this issue :)
, , , . :
".html" ".php".
.htaccess:AddDefaultCharset UTF-8
:
Firebug, , (Apache) , ISO-8859-1. UTF-8.
UTF-8
header("Content-Type: text/html; charset=utf-8");
.php , .html , , jQuery browser .innerHTML , Haboustak. . jQuery load.
jQuery load() innerHTML html, , . , html , . UTF-8 ISO 8859-1.
You need to fix this on the server, not in Javascript. The server code that responds to your source Html (which contains your jQuery) should include a content type header encoded with the right character. If you are using Php, I think you have found an example of how to do this.