Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/387.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AJAX请求失败_Javascript_Php_Html_Css_Ajax - Fatal编程技术网

Javascript AJAX请求失败

Javascript AJAX请求失败,javascript,php,html,css,ajax,Javascript,Php,Html,Css,Ajax,函数ajax(){ var xhttp=newXMLHttpRequest(); xhttp.onreadystatechange=函数(){ if(this.readyState==4&&this.status==200){ document.getElementById(“demo”).innerHTML=xhttp.responseText; 警报(this.responseText); } }; } xhttp.open(“POST”,“abcdef.xyz/abc/logincheck

函数ajax(){
var xhttp=newXMLHttpRequest();
xhttp.onreadystatechange=函数(){
if(this.readyState==4&&this.status==200){
document.getElementById(“demo”).innerHTML=xhttp.responseText;
警报(this.responseText);
}
};
}
xhttp.open(“POST”,“abcdef.xyz/abc/logincheck.php”邮件=abc@gmail.com&密码=abc”,为真);
xhttp.send()

主体元素的内容将显示在浏览器中。

点击我!
xhttp.open()
xhttp.send()
需要在
ajax()
函数中

function ajax() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("demo").innerHTML = xhttp.responseText;
      alert(this.responseText);
    }
  };
  xhttp.open("POST", "abcdef.xyz/abc/logincheck.php?mail=abc@gmail.com&password=abc", true);
  xhttp.send();
}

由于xhttp,open和send在功能块的外侧定义

xhttp.open("POST", "abcdef.xyz/abc/logincheck.php?mail=abc@gmail.com&password=abc", true);
xhttp.send();

您是否在函数中定义了xhttp?浏览器的web开发控制台中是否存在任何错误?