我正在请求一个回显一行的简单 php 文件;使用 AJAX,但我从 linux 上的 localhost 服务器收到 HTTP 501 响应。我的问题是,什么可能导致这种错误?
JavaScript:
var request = new XMLHttpRequest();
request.onreadystatechange = function () {
//console.log(request.responseText);
if (request.readyState == 4 && request.status == 200) {
console.log(0);
} else if (request.status == 501) {
console.log(request.responseText);
}
}
request.open('test.php', 'GET', true);
request.send();
测试.php:
<?php echo 'this is a test'; ?>