I have an array that looks like this (using var_dump in php):
string '[{"US":"2"},{"England":"0"},{"Mexico":"0"},{"France":"0"},{"Canada":"0"},{"Spain":"0"},{"Italy":"0"},{"Australia":"0"},{"Japan":"0"},{"China":"0"},{"Korea":"0"}]'
I need to extract both columns in javascript but I obviously fail whatever I tried
This is what I tried so far:
var dbdata = <?php echo json_encode($dataset1); ?>;
for (var key in dbdata) {
for (var key2 in dbdata[key]) {
alert("Country " + key2 + " No of member is " + key);
}
}
I get the country right, but the key is the index not the column value. How should be be fixed?
Thanks