I'm trying to loop the returning Array from PHP. But still don't get the way. Examples are ~
PHP:
$items = array();
$items["country"] = "North Korea",
$items["fruits"] = array(
"apple"=>1.0,
"banana"=>1.2,
"cranberry"=>2.0,
);
echo json_encode( $fruits );
jQuery:
$.ajax({
url: "items.php",
async: false,
type: "POST",
dataType: "JSON",
data: { "command" : "getItems" }
}).success(function( response ) {
alert( response.fruits.apple ); //OK
// <------ here, how do i loop the response.fruits ? -----
});
Then how can i loop to know which Fruits i got, please?