I'm getting a weird behavior out of javascript, anyone can help me?
When I click on the 'test' link I get an alert with this string: "[]"
I was expecting something like : "[{'temp':25},{'thermState':'Notte'}]"
What am I doing wrong?
<html>
<head>
<script type="text/javascript" charset="utf-8" src="js/json2.js"></script>
<script type="text/javascript" charset="utf-8">
function test(){
this.radioStates="";
this.state = [];
this.state["temp"]=25;
this.state["thermState"]="Notte";
alert(JSON.stringify(this.state));
}
</script>
</head>
<body>
<a href="#" onclick="test()">test</a>
</body>
</html>
this.state["temp"]=25should bethis.state{ "temp" : 25 }