i'm passing some values to a php file with ajax using the POST method.
When the php file receives special chars like à è ì it saw it correctly, but when i put it into a query they saves bad on the database.
Where i'm wrong? I tried to change charset to the mysql table... but nothing.
Here's my code.
Ajax File:
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var response = xmlhttp.responseText;
if(response == "error")
{
post_status.innerHTML = "<font color=\"red\">Si è verificato un errore</font>";
}
else if(response == "error_tofast")
{
post_status.innerHTML = "<font color=\"red\">Hai postato un commento meno di un minuto fa, attendi</font>";
}
else if(response == "posted")
{
post_status.innerHTML = "<font color=\"green\">Post aggiunto con successo</font>";
document.getElementById("newcommenttxt").value = "";
document.getElementById("newcommenttxt").rows = 2;
document.getElementById("list-comments").innerHTML = '<br><br><br><center><img style="cursor: progress;" width="60px" height="60px" src="./styles/images/loading.gif"></center>';
setTimeout("loadGagi()", 1000);
document.getElementById("reply_to_title").innerHTML = "";
replyto = -1;
}
}
}
//xmlhttp.open("GET","./includes/postgagi?userid="+userid+"&replyto="+replyto+"&txt="+edited_comment,true);
xmlhttp.open("POST","./includes/postgagi",true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
xmlhttp.send("userid="+userid+"&replyto="+replyto+"&txt="+edited_comment+"");