I’m having some big problems with encoding in Firefox when using AJAX and jQuery.
I pass a string with $.ajax(), and in the php code I’m using the function:
header("Content-Type: text/html; charset=ISO-8859-1",true);
jQuery:
$.ajax({
type: 'GET',
url: 'Filme_comparador_horarios.php',
data: 'cartaz='+$filme_compara,
success: function(retorno)
{
$('#cartaz_comp').append(retorno);
}
PHP:
if(isset($_GET["cartaz"]))
{
$cartaz = $_GET["cartaz"];
echo"
<div class='cartaz_comp_img'><img class='cartaz_comp_imagem' src='horarios/$cartaz/filme.jpg' width='140px' height='210px'/>
<div class='nome_comp'>$cartaz</div>
</div>
";
}
I already tried using:
echo utf8_decode($cartaz);
making it run ok in Firefox, but breaking in IE and Chrome.
You can try with htmlspecialchars in PHP, you can use the code below,
and in your Ajax page create this javascript function
in your ajax code