Come da titolo in questa chat in ajax non vedo le lettere accentate come posso fare?
Codice PHP:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Chat con: Nome utnete</title>
<script type="text/javascript">
/* Richiesta Ajax */
var http_request=false;
var http_request2=false;
var intUpdate;
function ajax_request(url){http_request=false;
if(window.XMLHttpRequest){http_request=new XMLHttpRequest();
if(http_request.overrideMimeType){http_request.overrideMimeType('text/xml');
}
}
else if(window.ActiveXObject){try{http_request=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){
try{http_request=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){}}}
if(!http_request){alert('Mi fermo : ( Impossibile creare una istanza XMLHTTP');
return false;
}
http_request.onreadystatechange=alertContents;
http_request.open('GET',url,true);http_request.send(null);
}
function alertContents(){
if(http_request.readyState==4)
{
if(http_request.status==200)
{rec_response(http_request.responseText);
}else{}
}
}
/* Lettura richiesta Ajax */
function ajax_request2(url){http_request2=false;
if(window.XMLHttpRequest){
http_request2=new XMLHttpRequest();
if(http_request2.overrideMimeType){http_request2.overrideMimeType('text/xml');
}
}
else if(window.ActiveXObject){
try{http_request2=new ActiveXObject("Msxml2.XMLHTTP");
} catch(e){
try{http_request2=new ActiveXObject("Microsoft.XMLHTTP");
} catch(e){}
}
}
if(!http_request2){alert('Mi fermo : ( Impossibile creare una istanza XMLHTTP');
return false;
}
http_request2.onreadystatechange=alertContents2;
http_request2.open('GET',url,true);
http_request2.send(null);
}
function alertContents2(){
if(http_request2.readyState==4){
if(http_request2.status==200){
rec_chatcontent(http_request2.responseText);
}else{}
}
}
/* Codice riguardante la chat */
waittime=2000;
intUpdate=window.setTimeout("read_cont()", waittime);
chatwindow.value = "connecting...";
function display_msg(msg1) {
/* riempio la textarea con il contenuto */
chatwindow.value = msg1;
}
function write_msg(msg1) {
ajax_request("chat.php?m=" + escape(msg1));
}
function submit_msg() {
/* invio il mio messaggio*/
write_msg(chatmsg.value);
chatmsg.value="";
}
function rec_response(str1) {
/* la risposta qui � data dallo script php*/
}
function rec_chatcontent(cont1) {
if (cont1 != "") {
out1 = "";
/* capovolgo i messaggi in modo da mostra prima l'ultimo inviato */
while (cont1.indexOf("\n") > -1) {
out1 = cont1.substr(0, cont1.indexOf("\n")) + "\n" + out1;
cont1 = cont1.substr(cont1.indexOf("\n") + 1);
}
out1 = unescape(out1);
if (chatwindow.value != out1) { display_msg(out1); }
intUpdate=window.setTimeout("read_cont()", waittime);
}
}
function read_cont() {
/* funzione per prvenire il buffering */
zeit = new Date();
ms = (zeit.getHours() * 24 * 60 * 1000) + (zeit.getMinutes() * 60 * 1000) + (zeit.getSeconds() * 1000) + zeit.getMilliseconds();
ajax_request2("chat.txt?x=" + ms);
}
function keyup(arg1) {
if (arg1 == 13) { submit_msg(); } }
</script>
</head>
<body>
<textarea id="chatwindow" rows="10" cols="80" style="border:1px solid #aaaaaa; padding:4px;" readonly></textarea><br>
<input id="chatmsg" type="text" size="20" style="border:1px solid #aaaaaa;" onkeyup="keyup(event.keyCode);"> <input type="button" value="ok" onclick="submit_msg()" style="cursor:pointer;border:1px solid gray;">
</body>
</html>