<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="text" value="test">
<input id="submit_button" type="button" value="submit">
<p id="prompt">test</p>
<script>
function sendData()
{
console.log("it is a test");
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("post", "test.php",true);
xmlHttp.send("iq=test");
xmlHttp.onreadystatechange = function(){
if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
document.getElementById("prompt").innerHTML = xmlHttp.responseText;
}
}
}
ob = document.getElementById("submit_button");
ob.addEventListener("click",sendData);
</script>
</body>
</html>
test.php如下
<?php
echo "it is a test";
?>
点击button后,我发现 console.log("it is a test"); 没有运行。
请问,这是什么原因?
你看看是不是过滤掉了
如果有过滤,把过滤清空,在看看
另外看看显示的等级,选为默认的等级