I have a similar problem: jQuery AJAX Character Encoding , but any solution mentioned there works for me.
I made three simple files to show the problem:
PHP file:
//prueba.php echo "nº one two € áéíóú";
JavaScript file (I am using jQuery)
//Javascript file function prueba() { $.ajax({ type: "GET", contentType: "application/x-www-form-urlencoded;charset=ISO-8859-1", url: "prueba.php", }).done(function( data ) { $("#prueba").text(data); //$("#prueba").html(data); //It does the same encoding error }); }
** HTML file: **
<html> <head> <title>E-COMMERCE</title> <meta content="text/html; charset=iso-8859-1" http-equiv=Content-Type> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <script src="javascript/jquery.js" type="text/javascript"></script> <script src="javascript/javascript.js" type="text/javascript"></script> </head> <body> <a href="javascript:prueba()">Prueba</a> <div id="prueba"></div> </body> </html>
And when you click the Prueba link, it shows:
Prueba n uno dos
The current site works fine, but it does not use ajax, and it is on the same server where I do it, so how can I tell jquery to return ISO-8859-1 instead of what it returns? I know that the ideal is to always use utf-8, but changing it to utf-8 will give us some problems that we cannot afford right now.
source share