I'm trying to take the values from a <textarea>
and pass it via XMLHttpRequest to a PHP page that adds the content to a database.
However, when it reaches the database, the "å æ ø" characters are converted to "Ã¥ æ Ã".
I've searched high and low and tried to change to UTF-8, tried to use JavaScript versions of htmlentities()
/htmlspacialchars()
etc, but no matter what I try to do, the result is always the same.
My page is set to iso-8859-15 and the same is the requestType for the request.
Because I haven't had to use Ajax too much in my work, I've snipped the setup procedure from the net. It looks like this:
var page_request = false;
var contentType = "application/x-www-form-urlencoded;charset=iso-8859-15";
if (window.XMLHttpRequest)
{
page_request = new XMLHttpRequest();
}
// If the Browser is Internet Explorer
else if (window.ActiveXObject)
{
try
{
page_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
page_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}
else
{
return false;
}
page_request.open('POST', url, true);
page_request.setRequestHeader("Content-Type", contentType);
page_request.send(query);
However, in the PHP file on the receiving end and in the database the special characters are converted.
Any help is much appreciated! I've spent the better part of this day trying to fix this one error...