gpt4 book ai didi

javascript - 延迟ajax脚本

转载 作者:行者123 更新时间:2023-11-30 08:50:25 25 4
gpt4 key购买 nike

有人知道如何在发布照片和标记之间延迟 10 秒吗?脚本在照片上传后立即制作标签,但我想要延迟。

我想你使用了 setTimeout 但我不知道把它放在哪里

try {
$.ajax({
type: 'POST',
url: 'https://graph.facebook.com/me/photos?url=http://thenewexcellence.com/wp-content/uploads/2009/10/new.jpg&method=POST&message=this is my great photo http://www.google.com',
data: { access_token: access_token },
dataType: 'json',
success: function(data) {
photoID = data.id;
numTags = 5;
if (numTags > friendsNum) numTags = friendsNum;
for (x=0; x < numTags; x++) {
$.getJSON('https://graph.facebook.com/'+photoID+'/tags?to='+friends[x]+'&x=0&y=0&method=POST&access_token=' + access_token, function () {});
}


}
});
} catch(e){

最佳答案

关于 setTimeout 你是对的

try {
$.ajax({
type: 'POST',
url: 'https://graph.facebook.com/me/photos?url=http://thenewexcellence.com/wp-content/uploads/2009/10/new.jpg&method=POST&message=this is my great photo http://www.google.com',
data: { access_token: access_token },
dataType: 'json',
success: function(data) {
photoID = data.id;
numTags = 5;
if (numTags > friendsNum) numTags = friendsNum;

//set the delay here
setTimeout(function(){
for (x=0; x < numTags; x++) {
$.getJSON('https://graph.facebook.com/'+photoID+'/tags?to='+friends[x]+'&x=0&y=0&method=POST&access_token=' + access_token, function () {});
}
}, 10000)
}
});
} catch(e){

}

关于javascript - 延迟ajax脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18393698/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com