-
-
Save FrankFang/d7fd8d773d2de5c115107f4b1a23f8b5 to your computer and use it in GitHub Desktop.
使用 http-server . -c-1 启动
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"word":"fuck you" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<title>JS Bin</title> | |
<button id=x>click me</button> | |
<div id="output" style="border: 1px solid red"> | |
</div> | |
<script> | |
x.onclick = function(){ | |
var request = new XMLHttpRequest() | |
request.open('GET', '/fuck') | |
request.setRequestHeader('Accept', 'text/html') | |
request.onreadystatechange = function(){ | |
if(request.readyState === 4){ | |
console.log(request.status) | |
console.log(request.statusText) | |
console.log(request.getAllResponseHeaders()) | |
var object = JSON.parse(request.responseText) | |
output.innerText = object.word | |
} | |
} | |
request.send('sadlkjasd;lksajd') | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment