<script type="text/javascript">
var myJSONObject = {"bindings": [
{"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"},
{"ircEvent": "PRIVMSG", "method": "deleteURI", "regex": "^delete.*"},
{"ircEvent": "PRIVMSG", "method": "randomURI", "regex": "^random.*"}
]
};
function send(myJSONObject){
var c = document.createElement('div');
var t = document.createTextNode(myJSONObject.bindings[1].regex);
c.appendChild(t);
document.body.appendChild(c);
}
</script>
</head>
<body>
<input type="button" value="go" onclick="send();" />
</body>
Can i access a json object in the above way by directly passing json object into a js function and including the value of it as the value of the text node - if not what are the things i am missing out? I want the dynamically created div to have the value of the json object in its text node. Thanks!