8,906
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<h1 id="displayBox"></h1>
<script>
// DisplayBox
function display(message) {
var displayBox = document.getElementById("displayBox");
displayBox.innerHTML = message;
}
// XMLHttpRequest
var xhr = new XMLHttpRequest();
xhr.onload = function () {
display(xhr.responseText);
};
try {
xhr.open("get", "content.txt", true);
xhr.send();
}
catch (ex) {
display(ex.message);
}
</script>
</body>
</html>
Clark