I hava 2 php files. index.php and preview.php
in the top of index.php I have this code
<meta http-equiv='Content-Type' content='Type=text/html; charset=utf-8'>
When I try to load content to index.php from preview.php using:
function preview_content(id)
{
var thebutton = '#previewButton';
$(thebutton).hide();
$('#preview_area').load('preview.php?id='+id);
}
the content loaded with characters like this M�laga CF
I tried to put the same utf-8 code in the top of preview.php but nothing changed. Is there any way to retrieve the content with UTF-8 charset?
Please be sure about preview.php's encoding is UTF-8. Your editor's default encoding applies newly created files but if you copied preview.php from somewhere else it's encoding might be different. Also adding header('charset=utf-8'); as first line to preview.php might help. Like this;
<?php
header('charset=utf-8');
// your code below here
.
.
.
You can also use .ajax() and specify contentType instead of .load();
function preview_content(id)
{
var thebutton = '#previewButton';
$(thebutton).hide();
$.ajax({
data: { "id" : id },
type: "GET",
url: "preview.php",
contentType: "application/x-www-form-urlencoded;charset=UTF-8",
success: function(output) {
$('#preview_area').html(output);
}
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With