我需要在完成以下操作后执行回调:
jQuery.globalEval(myUnknownContent);
但是,其中myUnknownContent
可能包含一些Ajax调用。到目前为止,我正在使用100毫秒的超时时间,但这不是一个优雅而可靠的解决方案。
感谢您的任何帮助!
var onCompletion = function(){
// put here the stuff you want done after all unknown content
}
var ajaxSent = false;
jQuery(document).ajaxSend(function(){ ajaxSent = true });
jQuery.globalEval(myUnknownContent);
if (ajaxSent) {
jQuery(document).ajaxStop(onCompletion);
} else {
onCompletion(); // use setTimeout(onCompletion,0) if you want it asynchronous
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句