Created
November 16, 2018 11:41
-
-
Save JohnnyBravoNL/7eaa8bdb35e95536a68877a4a2b10ba1 to your computer and use it in GitHub Desktop.
Show JSON as HTML in JavaScript
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="text/javascript"> | |
function CallWebAPI() { | |
var responseContainer = document.getElementById('response'); | |
var request = new XMLHttpRequest(); | |
request.open("get", "/api/global/initialize", false); | |
request.send(); | |
var data = JSON.parse(request.responseText); | |
responseContainer.innerHTML = JSON.stringify(data, undefined, 2); | |
} | |
</script> | |
</head> | |
<body> | |
<p> | |
<pre id="response"></pre> | |
</p> | |
<script type="text/javascript"> | |
CallWebAPI(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment