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)
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. Click here for more information about the callbacks.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.