Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javascript中具有动态参数的函数_Javascript - Fatal编程技术网

javascript中具有动态参数的函数

javascript中具有动态参数的函数,javascript,Javascript,我使用此函数从web服务检索数组 button.onclick = function(item) { var nonReplying = new Array(getNoreply(item)); console.log(nonReplying); setTimeout(unInviteUsers(item, nonReplying), 2500); }.bind(button, EventsArray[i]

我使用此函数从web服务检索数组

button.onclick = function(item) {
            var nonReplying = new Array(getNoreply(item)); 
            console.log(nonReplying);
            setTimeout(unInviteUsers(item, nonReplying), 2500);
        }.bind(button, EventsArray[i][1]);
然后是函数

    function unInviteUsers(event,nonReplying)
{

      //remember to parseInt() the first param, Event ID as well 
      for(var i = 0; i <= nonReplying.length; i++)  
        {
            unInvite(event,parseInt(nonReplying[0][i].replace('"','').replace('"','')),AccessToken);
        } 
}
    function unInvite(event, user)
{   

    $.ajax({
    url: 'https://graph.facebook.com/'+event+'/invited/'+user+'?access_token='+AccessToken,
    type: 'DELETE',
    success: function(result) 
    {
        console.log(JSON.stringify(result));
    }
    });
}
但是当button.onclick被触发时,数组的不可重复性将不会被传递,而未被邀请的用户将返回

TypeError:“undefined”不是计算“nonReplyingArray[0][i]”的对象。替换'

顺便问一下,我如何正确地强制一个函数等待另一个函数完全完成呢?

不执行实际上是一个二维数组吗

另外,除了未定义的错误

不会做你想做的事。我相信你想让那些不速之客在2.5秒后开火。setTimeout的第一个参数需要是对函数的引用。除非不速之客本身返回匿名函数,否则这不会起作用,但可能:

setTimeout(function() { unInviteUsers(item, nonReplying) }, 2500);

是的,它是一个双色的。arrayAh,另一件事:你的for循环的中止条件是,嗯,我以前试过这个,但实际上设置<,而不是
setTimeout(function() { unInviteUsers(item, nonReplying) }, 2500);