I'm newbie in javascript and My project can't use AJAX or any Framework . . .
It's simple code but still curious what's wrong with it
<html>
<head>
<script type="text/javascript" src="onejs.js"></script>
<link href="onecss.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="myDiv" class="subMenu" onclick="test(this)">CLICK</div>
</body>
</html>
onejs.js
function test(id) {
var s = document.createElement('script');
s.id = 'dynScript';
s.type='text/javascript';
s.src = "http://echo.jsontest.com/one/111oneoneone/key/value";
var obj = JSON.parse(s);
id.innerHTML = (obj.key);
}
When I click in "CLICK" it doesn't change.
JSON.parse, or the remote host providing the JSON allows you to specify a consumer callback (google JSONP).