[英]Simple $.getJSON(“adress”),function(res){ does not wok
I have a simple function: 我有一个简单的功能:
setInterval(function () {
$.getJSON("https://graph.facebook.com/v2.8/?ids=1234567_1234567&fields=reactions.type(LIKE).limit(0).summary(total_count).as(reactions_like)%2Creactions.type(LOVE).limit(0).summary(total_count).as(reactions_love)&access_token=thatsmytoken"),
function (res) {
console.log(res);
};
}, 5000);
So it should call GET and show the result in console but its not... I can see the result of GET in network info in Chrome (every 5 seconds it works fine) but its not going inside the function(res) 因此,它应该调用GET并在控制台中显示结果,但不是...我可以在Chrome的网络信息中看到GET的结果(每隔5秒钟它就可以正常工作),但是它不在函数内部(res)
Why is that? 这是为什么?
Your parentheses are incorrect. 您的括号不正确。 It should be:
它应该是:
setInterval(function () {
$.getJSON("https://graph.facebook.com/v2.8/?ids=1234567_1234567&fields=reactions.type(LIKE).limit(0).summary(total_count).as(reactions_like)%2Creactions.type(LOVE).limit(0).summary(total_count).as(reactions_love)&access_token=thatsmytoken",
function (res) {
console.log(res);
});
}, 5000);
Now, function(res){...} will be the callback of the getJSON function if it succeeds. 现在,如果成功,function(res){...}将是getJSON函数的回调。 Click here for more information about the callbacks.
单击此处以获取有关回调的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.