I'm unable to count the length of an Object
In an ajax call i retrieve a JSON object and count the number of result
throught lenght property. But in another code, with same kind of call and
little modifications to the server-side script, the length propertu
retrieve me alway undefined. Why? Note that in the developer console the
msg is treated like an object (i tink, converted automatically from JSON
by ajax), not such an array.
$.ajax({
url : 'richiediListaVideo.php',
type : 'POST',
data : data,
dataType : 'json',
success : function (msg)
{
alert(msg['videos'].length)
},
The object whose "undefined" length is something like
-video
--title
--duration
---tags
---8 "funny"
---1352 "animals"
---13 "Tv"
My goal is to retrieve the tags length, and i wrote
msg['video']['tags'].length
No comments:
Post a Comment