javascript - setTimeout in Winjs -
Regarding the server API, I should limit 3 seconds per requests. Here is my code:
groups.forEach (work (group) {Api.simpleRequest (uri). Then (function (res) {// processing result}, function (error) {/ / error handling }); }); What I tried to do: 1.
for (var i = 0; i & lt; groups.length; i ++) {(Function (index) {SetTimeout (function () {Api.simpleRequest (url). Then () // ...}, 1000);}) (i); }; Trying to use - WinJS.Promise.timeout (1000) , then continue my promise.
Both options do not work for me.
Just got the solution to work, but < setTimeout () var i = 0; Instead of strong> setInterval () Var length = groups. Long - 1; Var timer = setInterval (function () {Api.simpleRequest (uri) .then () // ... if (i == groups.length) {clearInterval (timer);}} i ++;});
Comments
Post a Comment