<head>
<script>
function getInfo(o)
{
var obj=o;
document.getElementById('test').innerHTML=obj.name1;
document.getElementById('test2').innerHTML=obj.name2;
}
</script>
</head>
<body>
<input type="button" value="submit" onclick='getInfo(${json})' />
<p>JSON values should appear below.</p>
<div id="test"></div>
<div id="test2"></div>
</body>
I'm trying to load the JSON object when the page loads, but I've been unsuccessful with various different ways... c:set var, body onload, mixing JSTL and JS...
Is there a way to load JSON objects as the page loads?
It's based on this example: http://java-x.blogspot.com/2007/04/using-json-from-java.html
Currently, it works, it loads the JSON object when I click the button, but I don't want clicking anything.