답변:
콜백 함수를 지정할 수 있습니다.
$(selector).fadeOut('slow', function() {
// will be called when the element finishes fading out
// if selector matches multiple elements it will be called once for each
});
jQuery 1.6 버전에서는이 .promise()방법을 사용할 수 있습니다 .
$(selector).fadeOut('slow');
$(selector).promise().done(function(){
// will be called when all the animations on the queue finish
});
promise()또는 when()과 done()심지어 자신의 당신이 제 3의 방법에서 아주 멋진 동작을 활용하거나. 의미 +1 .promise()!
$(selector).fadeOut('slow').promise().done(function(){...});
완료 $.when()될 때까지 대기 하는 데 사용할 수도 있습니다 promise.
var myEvent = function() {
$( selector ).fadeOut( 'fast' );
};
$.when( myEvent() ).done( function() {
console.log( 'Task finished.' );
} );
실패 할 수도있는 요청을 수행하는 경우 한 단계 더 나아갈 수도 있습니다.
$.when( myEvent() )
.done( function( d ) {
console.log( d, 'Task done.' );
} )
.fail( function( err ) {
console.log( err, 'Task failed.' );
} )
// Runs always
.then( function( data, textStatus, jqXHR ) {
console.log( jqXHR.status, textStatus, 'Status 200/"OK"?' );
} );
$.when()하지 않고 작업을 수행하기 위해 하나 이상의 약속을 통과하기를 기대 하기 때문에 작동 myEvent()하지 않습니다 $.when().