i have a json object that gets returned by an AJAX request and I am having some trouble with the .length
because it keeps returning undefined
.
(我有一个json对象,由AJAX请求返回,我遇到一些.length
因为它一直返回undefined
。)
Just wondering if I'm using it right:(只是想知道我是否正确使用它:)
console.log(data.length);
console.log(data.phones.length);
They both return undefined
even though they are valid objects.
(它们都返回undefined
即使它们是有效的对象。)
Update:
(更新:)
Sample of the JSON object returned:(返回的JSON对象示例:)
{"reqStatus":true,"phones":{"one":{"number":"XXXXXXXXXX","type":"mobile"},"two":{"number":"XXXXXXXXXX","type":"mobile"}}}
ask by nkcmr translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…