我试图让 AJAX 读取文本文件(有效),但它只会显示responseText
如果我alert()
在函数中有一个(我不想要)。
有没有办法让它在responseText
没有的情况下显示alert()
?这是我当前的代码。
<script type="text/javascript">
function load(){
var txtFile = new XMLHttpRequest();
txtFile.open("GET", "current.txt", true);
txtFile.send(null);
document.write(txtFile.responseText);
}
window.onload = load;
</script>