gpt4 book ai didi

jQuery - 在继续之前执行函数

转载 作者:行者123 更新时间:2023-12-01 06:56:59 26 4
gpt4 key购买 nike

如何停止执行函数,直到另一个函数完成为止?

$('#div').load( 'sub.html', function() {

//Do this once done loading the sub.html file
setTimeout(function() {

//Run SomeFunction(); before doing anyhing else
$('#tabsWrapper').removeClass('ajaxLoading');
$('#tabsWrapper #loaderDiv').fadeIn(500);

} , 1000);

});

我想确保在执行 $('#tabsWrapper').removeClass('ajaxLoading'); 等之前完成 SomeFunction()

有什么建议我可以如何实现这一目标吗?非常感谢任何帮助。

最佳答案

$('#div').load( 'sub.html', function(response, status) {

if(status=="success"){
//do your stuff here ..its loaded
}

});

关于jQuery - 在继续之前执行函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7873424/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com