Instantly share code, notes, and snippets.

What would you like to do?
Displaying JSON values with JavaScript : Basics of JSON Template with JavaScript
<!DOCTYPE html>
<meta charset=utf-8 />
<title>Displaying JSON values with JavaScript : Basics of JSON Templating with JavaScript</title>
<!--[if IE]>
<script src=""></script>
article, aside, figure, footer, header, hgroup,
menu, nav, section { display: block; }
function loadJSON(url){
var headID = document.getElementsByTagName("head")[0];
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.src = url;
function show(obj){
var elems = document.getElementsByTagName("span");
for(i=0; i<=elems.length; i++){
var bind = elems[i].getAttribute("data");
if(bind && obj[bind]){
elems[i].innerHTML = obj[bind];
<p>ID: <span data="id"></span></p>
<p>Name: <span data="name"></span></p>
<p>link: <span data="link"></span></p>
<a href="" ></a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment