更新时间:2023-12-05 11:02:16
如果您使用的是jQuery 1.5,则有两种新方法可以处理:延迟和承诺。
If you are using jQuery 1.5, there are two new ways to handle this: deferred and promises.
使用jQuery Deferred和Promises创建响应式应用程序
function successFunc(){
console.log( "success!" );
}
function failureFunc(){
console.log( "failure!" );
}
$.when(
$.ajax( "/main.php" ),
$.ajax( "/modules.php" ),
$.ajax( "/lists.php" )
).then( successFunc, failureFunc );
例如,要在您的实例中使用它,只需替换 ajax
请求加载
。
To use this in your instance, for example, just replace the ajax
requests with load
.