I thought this would be much simpler but I'm having some difficulty finding a simple answer online.
I simply want to get data from an MySQL table with ajax and transform it into a js array.
My table is ultra simple.. it's just:
Table 1
id value
1 1
2 2
3 3
What is the best way to do this?
So far I have the php file:
while($row = mysql_fetch_array($query)) {$array[] = $row;}
which emits something like:
Array ( [0] => Array ( [0] => 7 [idGlobal] => 7 [1] => 4.9 [tc] => 4.9 ) ) Array ( [0] => Array ( [0] => 7 [idGlobal] => 7 [1] => 4.9 [tc] => 4.9 ) [1] => Array ( [0] => 3 [idGlobal] => 3 [1] => 2.2 [tc] => 2.2 ) ) Array ( [0] => Array ( [0] => 7 [idGlobal] => 7 [1] => 4.9 [tc] => 4.9 ) [1] => Array ( [0] => 3 [idGlobal] => 3 [1] => 2.2 [tc] => 2.2 ) [2] => Array ( [0] => 5 [idGlobal] => 5 [1] => 1.9 [tc] => 1.9 ) ) Array ( [0] => Array ( [0] => 7 [idGlobal] => 7 [1] => 4.9 [tc] => 4.9 ) [1] => Array ( [0] => 3 [idGlobal] => 3 [1] => 2.2 [tc] => 2.2 ) [2] => Array ( [0] => 5 [idGlobal] => 5 [1] => 1.9 [tc] => 1.9 ) [3] => Array ( [0] => 6 [idGlobal] => 6 [1] => 1.9 [tc] => 1.9 ) ) Array ( [0] => Array ( [0] => 7 [idGlobal] => 7 [1] => 4.9 [tc] => 4.9 ) [1] => Array ( [0] => 3 [idGlobal] => 3 [1] => 2.2 [tc] => 2.2 ) [2] => Array ( [0] => 5 [idGlobal] => 5 [1] => 1.9 [tc] => 1.9 ) [3] => Array ( [0] => 6 [idGlobal] => 6 [1] => 1.9 [tc] => 1.9 ) [4] => Array ( [0] => 4 [idGlobal] => 4 [1] => 1.6 [tc] => 1.6 ) )
but I still don't know the best way to get it with ajax to a JS array