Sunday, 15 July 2012

javascript - How to refactor this code if I need to rate-limit it's execution speed -


I was thinking, I can use the sleep function - but javascript does not work for sleep.

How can I slow down a bit to stop the parsight rate? I want to execute one (1) pars.clid.ron method every 5 seconds.

  $ ('website') each (function (i) {var website = $ (this) .text (); Parse.Cloud.run ('getMainEmail', {url: website }, {Success: work (result) {cell.next (). Text (result);}, error: Function (error) {console.log ("Email for website could not be found:" + website); console Log (error);}});  

Currently, this code finds all the websites in the DOM and a TON fire of parsed requests at the same time - which gives me the rate of approx. Immediately decreases.

just Use Setimeme and pass the website as a passmaster

  $ ('website'). (Function (i) {var website = $ (this) .text (); SetTimeout (pane.clood.run ('getMainEmail', {url: siteText}, {success} function (result) {cell.next (). Text (result);}, error: function (error) {Console.log ("Email for website could not be found:" + sitetext); console.log (error);}}, (I + 1) * 5000, website);});  

No comments:

Post a Comment