jquery - Javascript asynchronous execution queue and setTimeout? -
i have script need bump out of javascript execution queue. have found can couple methods.
alert();//of course can't use one. settimeout(function(){ somescript();//works, there vulnerabilites? }, 1); what other methods there , correct way bump out of javascript execution queue?
if settimeout best option, vulnerabilities of using settimeout? there possible future problems, possibility code in timeout won't called, speed issues, etc.
settimeout typical way of interrupting execution flow. alert() not same thing, synchronous - stop code until ok pressed, , resume left off. when use settimeout, frees thread go execute section of code.
the vulnerabilities not knowing doing. coding async little trickier coding sync. , have watch context, because using "this" won't work:
object = { firstmethod: function(){ settimeout(function(){ this.secondmethod(); // won't work! }, 30); }, secondmethod: function(){} }
Comments
Post a Comment