[英]jquery, javascript and callback timing
var blah = Some.Thing(data, function(a,b) {
// code here
});
Some.Thing = function(data, callback) {
if(...) {
var a = Other.Thing(data, function() {
// code here
callback();
return;
});
}
callback();
};
My question is, will the part that says //code here
fire only after everything else and their callbacks fire? 我的问题是,是否会说,部分//code here
只火一切,他们的回调火灾后?
The //code here
part seems to fire, and there seems to be some timing issue. //code here
的//code here
部分似乎已启动,并且似乎存在一些计时问题。
You're not actually using callback
anywhere in Some.Thing
, so it's impossible to say. 实际上,您并没有在Some.Thing
任何地方使用callback
,所以这很难说。 But yes, generally, unless something actually calls callback
, the code within it is not executed. 但是是的,通常,除非实际调用了 callback
,否则其中的代码不会执行。 It is evaluated (parsed), but not executed. 它被评估(分析),但是不执行。
That is impossible to tell from the code you supplied. 从您提供的代码中看不出来。
The method callback
can either be called while on the same stack, or its execution might be deferred due to ajax or setTimeout being used (asynchronous). 该方法callback
既可以称为同时相同的堆栈上,或它的执行可能被推迟由于AJAX或setTimeout的正在使用的(异步)。
If being deferred, then it would be called only after the main method has completed and the thread going back to idle. 如果被延迟,则只有在main方法完成并且线程返回空闲状态之后才调用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.