[英]how to call a function after another function with ajax call completes
Here are two functions in javascript: 这是javascript中的两个函数:
function func1() {
setTimeout(function() {
$.ajax({
...
});
}, 120000);
}
function func2() {
// do something
}
Is there a way to execute func2 after func1 returns? func1返回后,有没有一种执行func2的方法?
Here I don't want to pass func2 into func1 as a callback, because func2 is for testing purpose. 在这里,我不想将func2作为回调传递给func1,因为func2用于测试。
just call after success
or error
success
或error
后再打电话
$.ajax({
...
success: function(resp) {
func2();
}
error: function(resp) {
func2();
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.