<script src="http://vkontakte.ru/js/api/openapi.js" type="text/javascript">
</script>
<div id="login_button" onclick="VK.Auth.login(getit);"></div>
<script language="javascript">
VK.init({
apiId: 2903251
});
function getit(response) {
if (response.session) {
var id = response.session.mid;
}
VK.Api.call('users.get', {uids: id, fields: 'sex,photo_big'}, function(r) {
if(r.response) {
alert(r.response.sex);
console.log(r.response);
}
});
}
VK.UI.button('login_button');
</script>
为什么alert(r.response.sex)
显示未定义,但控制台日志一切正常?
答案 0 :(得分:1)
解决。解决方案: r.response [0] .sex