1

写真を投稿してからタグ付けするまでに 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){
4

2 に答える 2

5

あなたは 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){

}
于 2013-08-23T02:29:56.823 に答える