Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Displaying JSON values with JavaScript : Basics of JSON Templating with JavaScript</title>
<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
  article, aside, figure, footer, header, hgroup, 
  menu, nav, section { display: block; }
</style>
</head>
<body>
  <p>ID: <span data="Message"></span></p>
  <p>Name: <span data="Message"></span></p>
  <p>link: <span data="Message"></span></p>
  Blog post: <a href="http://motyar.blogspot.com/2011/12/displaying-json-values-with-javascript.html" >Displaying JSON values with JavaScript : Basics of JSON Template with JavaScript</a>
</body>
</html>
 
function loadJSON(url){
    var headID = document.getElementsByTagName("head")[0];         
    var newScript = document.createElement('script');
    newScript.type = 'text/javascript';
    newScript.src = url;
    headID.appendChild(newScript);
}
function show(obj){
    var elems = document.getElementsByTagName("span");
    for(i=0; i<=elems.length; i++){
        var bind = elems[i].getAttribute("Message");
        
        if(bind && obj[bind]){
            elems[i].innerHTML = obj[bind];
        }
    }
}
loadJSON('http://allrecipes.com/services/client.svc/Recipe/235603');
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers