我有一个html
和php
文件:
test.html
:
var req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (req.readyState==4 && req.status == 200) {
var dat = req.reponseText;
alert("Status text: " + req.statusText);
alert("Response: " + dat);
}
};
req.open("GET", "info.php", true);
req.send();
和info.php
:
<?php
echo "test";
?>
访问info.php
按预期显示“test”,但AJAX请求中的responseText
始终未定义。我在这里缺少什么?
答案 0 :(得分:4)
TYPO TYPO TYPO
var dat = req.reponseText;
^^^