I'm trying to loop the returning Array from PHP. But jQuery .length is giving me:
'undefined'
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 );
    alert( response.length );
});
- Here the First Alert() is ok, by returning: "1.0".
- Then the Second Alert() to detect length response.lengthis returning:- undefined
 
Then how can i loop this Array (or) how to loop the Fruits (defined by PHP like $items["fruits"]) from jQuery end please?
 
     
     
     
     
     
     
    