nulla di tutto ciò.
dato che scrivendo le stesse funzioni nell'html andava tutto bene, non pensavo fosse importante lo script. provvedo a postarlo.
codice:
var SendChaturl = "sendchat.php";
function getHTTPObject() {
var xmlhttp;
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
function sendComment() {
currentChatText = document.forms['chatForm'].elements['chatbarText'].value;
messaggio = encodeURIComponent(currentChatText);
if (messaggio != '' & (httpSendChat.readyState == 4 || httpSendChat.readyState == 0)) {
currentName = document.forms['chatForm'].elements['locaz'].value;
param = 'Tag='+ currentName+'&Messaggio='+ messaggio;
httpSendChat.open("POST", SendChaturl, true);
httpSendChat.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
httpSendChat.onreadystatechange = handlehHttpSendChat;
httpSendChat.send(param);
document.forms['chatForm'].elements['chatbarText'].value = '';
document.forms['chatForm'].elements['chatbarText'].focus();
} else {
setTimeout('sendComment();',1000);
}
}
function handlehHttpSendChat() {
if (httpSendChat.readyState == 4) {
prenditesto();
}
}
var httpReceiveChat = getHTTPObject();
var httpSendChat = getHTTPObject();
ecco, queste funzioni, messe nell'html con i relativi tag script, ovviamente, funziona perfettamente. se però piglio sto malloppo e lo porto in un js, aggiungendo la relativa dichiarazione nel html, non funziona più nulla.
no, non uso window.onload. il file html in cui tutto ciò è compreso ha un body onload di però altre funzioni, non inerenti a questo che si attiva solamente quando viene spedita un testo in un campo input.