gpt4 book ai didi

javascript - 如何将以下同步代码重写为异步?

转载 作者:行者123 更新时间:2023-12-03 10:08:37 24 4
gpt4 key购买 nike

如何使用async_ajax()重写它?

function some_event_handler () {
if (condition) {
sync_ajax();
ajax_dependent_code1;
} else {
ajax_independent_code;
}
ajax_dependent_code2;
}

最佳答案

我通过以下方式做到了:

function some_event_handler () {
async_ajax(callback_function () {
if (condition) {
ajax_dependent_code1;
} else {
ajax_independent_code;
}
ajax_dependent_code2;
});
}

希望一切顺利……

关于javascript - 如何将以下同步代码重写为异步?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30243773/

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