Ciao a tutti!
Ho creato una pagina con ajax e avrei un problema con i caratteri.
Quando provo ad inserire una stringa processata con il comando htmlentities in un database con delle parole accentate, se lo richiamo tramite uno script scritto solamente in php il testo mi compare correttamente, mentre se provo a richiamarlo con uno script in ajax, le parole accentate sono convertiti in codice. Ora come posso fare per evitare questo problema?
Questo è lo script ajax:
codice:
function CreateXmlHttpReq(handler) {
var xmlhttp = null;
try {
xmlhttp = new XMLHttpRequest();
} catch(e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
xmlhttp.onreadystatechange = handler;
return xmlhttp;
}
function myHandler() {
if (myRequest.readyState == 4 && myRequest.status == 200) {
document.getElementById('testo').innerHTML=myRequest.responseText;
}
}
function testo(parametro1, parametro2) {
var r=Math.random();
myRequest = CreateXmlHttpReq(myHandler);
myRequest.open("GET","Testo.php?parametro1="+parametro1+"¶metro2="+parametro2+"&rand="+escape(r));
myRequest.send(null);
}
Grazie mille a tutti per l'aiuto.