I want to get the value of json array using .each
here's where I set the values of array
$allRecords= array();
while($row = mysql_fetch_array($result)){
$oneRecord[] = array("orderNo"=>$row['order_no'],"orderDate"=>$row['order_date'],"orderTime"=>$row['order_Time']);
array_push(&$allRecords,$oneRecord);
}
echo json_encode($allRecords);
and here's what I make in jquery
$.post("controllers/OrderViewer.controller.php?action=viewOrders",param,function(result){
// var data = JSON.parse(result); // I tried this but doesn't work
// var data= eval(result); // I tried this but doesn't work
$.each(result,function(index,v){
alert(index +" "+ v.orderNo); // return undefined for values
// what should I write here to reach array element
});
});
what should I write in .each to get array elements
here's the response data structure
Array
(
[0] => Array
(
[orderNo] => 1
[orderDate] => 2011-02-12
[orderTime] => 00:00:10
)
[1] => Array
(
[orderNo] => 2
[orderDate] => 2011-02-12
[orderTime] => 11:10:00
)
)