当我运行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;
}
}
}
答案 0 :(得分:0)
你的查询字符串是错误的(上面有太多问号字符)。将其更改为:
queryString = "name=" + name + "&company=" + company + "&nationalities=" + nationality + "&phonenumber=" + phonenumber + "&URL=newuser";
xmlHttp.open("GET", "index.php?" + queryString, true);