Skip to content

Instantly share code, notes, and snippets.

@jtulk
Last active August 29, 2015 14:23
Show Gist options
  • Save jtulk/0e38b033a3160e186b56 to your computer and use it in GitHub Desktop.
Save jtulk/0e38b033a3160e186b56 to your computer and use it in GitHub Desktop.
Trying out Bl.ocks.org with D3 and JSON-Generator
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="chart"></div>
<script src="main.js"></script>
</body>
</html>
var r = new XMLHttpRequest();
r.onreadystatechange = function () {
if (r.readyState != 4 || r.status != 200){
alert('Request Failed');
return false;
} else {
var data = JSON.parse(r.responseText);
processData(data);
}
};
r.open("GET", "http://beta.json-generator.com/api/json/get/H6eos0I");
r.send(null);
function processData(data){
document.getElementById('chart').innerHTML = "Request succeeded";
alert(data);
}
* {
box-sizing: border-box;
}
#chart {
border: solid 2px black;
height: 300px;
width: 100%;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment