So I have a php script that does this:
$rows = array();
while($r = mysql_fetch_assoc($sth2)) {
$rows[] = array($r['alternative'] => $r['amount']);
}
print json_encode($rows);
I get this output:
[{"\u00e5l":"3"},{"vin":"3"},{"whiskey":"1"},{"gin":"1"},{"rom":"1"},{"vodka":"1"}]
Problem one: \u00e5 is supposed to be ø. Everything else works with utf8 except this very function, any idea how to fix this?
Second problem is that I cannot seem to get a nice way of reading the data in javascript. I am currently using this code (I know’s not that good, but it should work for now):
$.each(obj, function(key, val)
{
counter = counter +1 ;
switch (counter)
{
case 0:
numberOne = key;
valueOne = val;
break;
case 1:
numberTwo = key;
valueTwo = val;
break;
case 2:
numberThree = key;
valueThree = val;
break;
case 3:
numberFour = key;
valueFour = val;
break;
case 4:
numberFive = key;
valueFive = val;
break;
case 5:
numberSix = key;
valuesix = val;
break;
}
});
for your second problem you can use
You havn’t specified what you want to achive by reading object properties So I left it to you 🙂 hope it helps.
edited :