Skip to content

Instantly share code, notes, and snippets.

@oha-yashi
Last active April 23, 2020 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oha-yashi/3979da0b9ef14dabe4e4255c341a983e to your computer and use it in GitHub Desktop.
Save oha-yashi/3979da0b9ef14dabe4e4255c341a983e to your computer and use it in GitHub Desktop.
localhosttest
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>
ろ〜かるほすとてすと
</title>
</head>
<body>
<h1>welcome to <span id="titlespace"></span></h1>
<button id="getohabutton">get oha.txt</button>
<p>上のボタンを押すと下に<code>oha.txt</code>の内容がでる</p>
<p id="status"></p>
<p id="result"></p>
<pre id="ohaspace"></pre>
<script src="main.js"></script>
</body>
</html>
const titlespace = document.getElementById("titlespace");
titlespace.textContent = document.title;
const getohabutton = document.getElementById("getohabutton");
const status = document.getElementById("status");
const result = document.getElementById("result");
const ohaspace = document.getElementById("ohaspace");
getohabutton.onclick = function(){
status.textContent = "クリックされました"
var url = "oha.txt"
var xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.responseType = "text";
xhr.onload = function(){
result.textContent = "読み込みました↓↓↓"
ohaspace.textContent = xhr.response;
}
xhr.send();
}
おは〜〜〜☀︎
読み込めましたか?
めでたし。
🤗🤗🤗🤗🤗
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment