开发者

Javascript Value in Object returns Undefined

开发者 https://www.devze.com 2023-03-26 15:14 出处:网络
I\'m doing an AJAX request with jQuery and trying to access the value in an object that is returned by the Post request , but when i try to use it like this result.VideoCode it shows undefined ( using

I'm doing an AJAX request with jQuery and trying to access the value in an object that is returned by the Post request , but when i try to use it like this result.VideoCode it shows undefined ( using console.log ) but when i do a console.log(result) it shows that the开发者_开发百科re is an object and there is data in it

here is a screenshot

Javascript Value in Object returns Undefined

Any ideas tho why this is happening and how can i fix it ?

Update:// the server was returning an array of objects with a single object in it ... so that solved the mystery ... should have figured it out earlier


Looking at the screenshot, result is an array containing one object.

You'd need to access it like:

result[0].VideoCode

which means: The first element of results, then from that object the VideoCode property.

0

精彩评论

暂无评论...
验证码 换一张
取 消