看到Status Code: 200 OK了,但最后点击之后 提示“发生错误:0”,请问代码哪里写错了?
<script type="text/javascript">
document.getElementById("button").onclick = function() {
var request = new XMLHttpRequest();
request.open("POST", "http://test.xzqlovexhh.top/hhj.php", true);
request.setRequestHeader("content-type", "application/x-www-form-urlencoded");
request.send("123");
request.onreadystatechange = function() {
if(request.readyState === 4) {
if(request.status === 200) {
document.getElementById("p").innerHTML = request.responseText;p
} else {
alert("发生错误:" + request.status);
}
}
}
}
</script>