当我运行 newuser() 函数时,它应该将一些信息发送回 index.php 文件。但是当我运行它时,什么也没有发生。我尝试了很多方法来找出问题所在,但没有运气。你们有人能在这段代码中发现问题吗?还是我应该编码的其他方式?
function newuser() {
if (xmlHttp.readyState == 0 || xmlHttp.readyState == 4) {
name = encodeURIComponent(document.getElementById("name").value);
company = encodeURIComponent(document.getElementById("company").value);
nationality = encodeURIComponent(document.getElementById("nationality").value);
phonenumber = encodeURIComponent(document.getElementById("phonenumber").value);
queryString = "name=" + name + "&company=" + company + "&nationalities=" + nationality + "&phonenumber=" + phonenumber + "&URL=newuser";
xmlHttp.open("GET", "index.php?" + queryString, true);
xmlHttp.onreadystatechange = handleServerRespons;
xmlHttp.send();
}else{
setTimeout('newuser()', 1000)
}
}
function handleServerRespons(){
if (xmlHttp.readyState == 4){
if (xmlHttp.readyState == 200){
xmlResponse = xmlHttp.rsponseXML;
xmlDocumentElement=xmlResponse.documentElement;
message = xmlDocumentElement.firstChild.data;
document.getElementById("underinput").innerHTML = message;
}
}
}