最近我想到了在JS参数列表中将这种方式发送给另一个函数-我错了吗?
func(parameters.response.items)
代码
Request('friends.get', {fields: 'photo_100', count: 5, v: 5.95}, function(data) {
console.log(data);
Draw(data.response.items);
})
function Draw(friends) {
$('#some').html(friends[1].id);
}
整个proyect在http://77.246.157.26/上可用
浏览器控制台TypeError: friends[1] is undefined
中的错误
但是console.log()
可以正确且完整地打印所有内容
答案 0 :(得分:0)
转到您的网站,很快便对其进行了检查。
您的AJAX调用中的数据出现错误。
jQuery33105943325674648605_1558658520581({"error":{"error_code":5,"error_msg":"User authorization failed: access_token was given to another ip address.","request_params":[{"key":"oauth","value":"1"},{"key":"method","value":"friends.get"},{"key":"fields","value":"photo_100"},{"key":"count","value":"5"},{"key":"v","value":"5.95"},{"key":"callback","value":"jQuery33105943325674648605_1558658520581"},{"key":"_","value":"1558658520582"}]}});
首先检查错误:
Request('friends.get', {fields: 'photo_100', count: 5, v: 5.95}, function(data) {
if(!data.error) {
//console.log(data);
if(data.response.items) {
Draw(data.response.items);
} else {
console.log("Unexpected json object format.");
}
} else {
alert(data.error.error_msg);
}
});