[jQuery] What is IE7 barfing at this js?
<html>
<body>
Hi folks,
The following snippet processes a JSON string sent back to the browser
(it is part of a poll)
<tt>function loadResults(data) {
var OPT_VOTES = 2;
var total_votes = 0;
for (id in data) {
total_votes =
total_votes+parseInt(data[id][OPT_VOTES]);
<x-tab> </x-tab><x-tab>
</x-tab>
alert("total_votes="+total_votes+" --- " +
data[id][OPT_VOTES]);
}
}
The JSON string looks like this...
</tt><pre>[["1","High cost","23","What
is the biggest challenge to recycling irrigation
water?"],["2","Disease and algae
management","12","5"],["3","Plentiful
and cheap water","8","4"]]
</pre>The problem I'm having is that IE7 appears to see 4 rows in the
array - and consequently returns "total_votes=NaN ---
undefined" at the first alert and "total_votes=NaN --- 23"
at the second loop and so on.
FF, Opera, and Safari all handle the code without problem - can anyone
help me understand what IE7 is getting upset about?
Thanks,
Bruce</body>
</html>