Hi guys i would like to ask how do you count the size of an array? i have an array that gets its value from the json_encode value passed by my php file... here is the format of my php return json data
<?php
$idArr= array();
while($row= mysql_fetch_array($outputArrayResult)){
$idArr["" . $row['id']] = false;
}
echo json_encode(array("total_pages" => $num_pages,"ids" => $idArr));
?>
which returns in this format
{
"total_pages":12,
"ids":{"1":false,"2":false,"3":false,"4":false,"5":false,"6":false,"7":false,"8":false,"9":false,"10":false,"11":false,"12":false}
}
now in my javascript i handle the ajax data returned using this code
success: function(data){
var obj = jQuery.parseJSON(data);
var ids= obj.ids;
alert("this is " + ids.length + " -- " + ids["2"]);
}
as you can see im retrieving the data using jQuery.parseJSON(data) and pass it to my variable ids. now when i try to alert the value it gives me this output
this is undefined -- false
so it means it successfully retrieved the value of ids["2"] but i cant get the length of the array to output properly... how do you do this?