Skip to content

Instantly share code, notes, and snippets.

@Franks-Joseph
Created October 14, 2018 03:40
Show Gist options
  • Save Franks-Joseph/3ad11cd83323afb89e460f2cb4583aff to your computer and use it in GitHub Desktop.
Save Franks-Joseph/3ad11cd83323afb89e460f2cb4583aff to your computer and use it in GitHub Desktop.
XHR_with_JSON created by Franks_Joseph - https://repl.it/@Franks_Joseph/XHRwithJSON
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>repl.it</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script src="script.js">
</script>
</body>
</html>
{
"Game": "Halo",
"Level": "Silent Cartogropher",
"Difficulty": "Legendary"
}
const xhr = new XMLHttpRequest();
xhr.onload = function() {
const jasonObject = JSON.parse(this.responseText);
alert(jasonObject.Game);
console.log("Success!");
}
xhr.open('get', 'info.json');
xhr.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment