是否可以确保在always
回调完成其工作后调用传递给function(data)
函数的回调?
$.get(link, function(data) {
// Do some stuff
}).always(function() {
// Will this callback be called after "do some stuff" finished its work?
});
答案 0 :(得分:1)
是的,它应该是真的,请查看 documentation 下面的示例:
var jqxhr = $.ajax( "example.php" )
.done(function() {
alert( "success" );
})
.fail(function() {
alert( "error" );
})
.always(function() {
alert( "complete" );
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>