Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/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 修复setInterval上的Firefox抛出错误。_Javascript_Google Chrome_Firefox - Fatal编程技术网

Javascript 修复setInterval上的Firefox抛出错误。

Javascript 修复setInterval上的Firefox抛出错误。,javascript,google-chrome,firefox,Javascript,Google Chrome,Firefox,为什么setInterval(fetchData(),1000*60)在Chrome中工作,同时抛出错误Firefox;我想将一个变量传递到fetchdata中 function fetchData(var) { ..... }; fetchData(var); //run once setInterval(fetchData(var), 1000*60); //then repeat 堆栈跟踪: [10:26:49.764] Error: us

为什么
setInterval(fetchData(),1000*60)在Chrome中工作,同时抛出错误Firefox;我想将一个变量传递到fetchdata中

   function fetchData(var) {
        .....
    };

    fetchData(var); //run once
    setInterval(fetchData(var), 1000*60); //then repeat
堆栈跟踪:

[10:26:49.764] Error: useless setInterval call (missing quotes around argument?)
userController@http://localhost:8000/mainx.js:169
invoke@http://localhost:8000/lib/angular.js:2809
instantiate@http://localhost:8000/lib/angular.js:2819
@http://localhost:8000/lib/angular.js:4639
applyDirectivesToNode/nodeLinkFn/<@http://localhost:8000/lib/angular.js:4218
forEach@http://localhost:8000/lib/angular.js:117
nodeLinkFn@http://localhost:8000/lib/angular.js:4203
compositeLinkFn@http://localhost:8000/lib/angular.js:3851
publicLinkFn@http://localhost:8000/lib/angular.js:3763
bootstrap/</<@http://localhost:8000/lib/angular.js:932
Scope.prototype.$eval@http://localhost:8000/lib/angular.js:7840
Scope.prototype.$apply@http://localhost:8000/lib/angular.js:7920
bootstrap/<@http://localhost:8000/lib/angular.js:930
invoke@http://localhost:8000/lib/angular.js:2802
bootstrap@http://localhost:8000/lib/angular.js:929
angularInit@http://localhost:8000/lib/angular.js:904
@http://localhost:8000/lib/angular.js:14527
p.Callbacks/k@http://localhost:8000/lib/jquery-1.8.2.min.js:2
p.Callbacks/l.fireWith@http://localhost:8000/lib/jquery-1.8.2.min.js:2
.ready@http://localhost:8000/lib/jquery-1.8.2.min.js:2
D@http://localhost:8000/lib/jquery-1.8.2.min.js:2
[10:26:49.764]错误:setInterval调用无效(参数周围缺少引号?)
userController@http://localhost:8000/mainx.js:169
invoke@http://localhost:8000/lib/angular.js:2809
instantiate@http://localhost:8000/lib/angular.js:2819
@http://localhost:8000/lib/angular.js:4639
applyDirectivesToNode/nodeLinkFn/使用

你所做的根本不是通过你的论点。您需要将其包装在

中使用


你所做的根本不是通过你的论点。您需要将其包装为

此语法不正确。不能使用setTimeout或setInterval传递这样的变量

setInterval(fetchData(var), 1000*60); //then repeat
改用以下方法

setInterval(function() {
    fetchData(var);
}, 1000*60);

此语法不正确。不能使用setTimeout或setInterval传递这样的变量

setInterval(fetchData(var), 1000*60); //then repeat
改用以下方法

setInterval(function() {
    fetchData(var);
}, 1000*60);