[英]Simple $.getJSON(“adress”),function(res){ does not wok
我有一個簡單的功能:
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);
因此,它應該調用GET並在控制台中顯示結果,但不是...我可以在Chrome的網絡信息中看到GET的結果(每隔5秒鍾它就可以正常工作),但是它不在函數內部(res)
這是為什么?
您的括號不正確。 它應該是:
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);
現在,如果成功,function(res){...}將是getJSON函數的回調。 單擊此處以獲取有關回調的更多信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.