deferred.done (doneCallbacks [, doneCallbacks])
deferred.done (doneCallbacks [, doneCallbacks])
설명 : 지연된 개체가 해결 될 때 호출 할 처리기를 추가합니다.
이 deferred.done()메서드는 하나 이상의 인수를 받아들입니다. 인수는 모두 단일 함수 또는 함수 배열 일 수 있습니다. Deferred가 해결되면 doneCallbacks가 호출됩니다. 콜백은 추가 된 순서대로 실행됩니다. deferred.done()지연된 객체를 반환하기 때문에 추가 .done()메서드를 포함하여 지연된 객체의 다른 메소드를이 객체에 연결할 수 있습니다 . 해결 된되는 이연 때, doneCallbacks이 제공 한 인수하여 실행 resolve또는 resolveWith그들이 추가 된 순서대로 메소드 호출을. 자세한 내용은 지연 객체에 대한 설명서를 참조하십시오 .
예 :
이 jQuery.get메서드는 Deferred 객체에서 파생 된 jqXHR 객체를 반환하기 때문에 메서드를 사용하여 success 콜백을 연결할 수 있습니다 .done().
$.get( "test.php" ).done(function() {
alert( "$.get succeeded" );
});
사용자가 버튼을 클릭 할 때 Deferred 객체를 해결하여 여러 콜백 함수를 트리거합니다.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>deferred.done demo</title>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<button>Go</button>
<p>Ready...</p>
<script>
// 3 functions to call when the Deferred object is resolved
function fn1() {
$( "p" ).append( " 1 " );
}
function fn2() {
$( "p" ).append( " 2 " );
}
function fn3( n ) {
$( "p" ).append( n + " 3 " + n );
}
// Create a deferred object
var dfd = $.Deferred();
// Add handlers to be called when dfd is resolved
dfd
// .done() can take any number of functions or arrays of functions
.done( [ fn1, fn2 ], fn3, [ fn2, fn1 ] )
// We can chain done methods, too
.done(function( n ) {
$( "p" ).append( n + " we're done." );
});
// Resolve the Deferred object when the button is clicked
$( "button" ).on( "click", function() {
dfd.resolve( "and" );
});
</script>
</body>
</html>
게시판 목록
개발자팁
질문은 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4586 | jQuery |
프로그래머7
|
8년 전 | 2088 | |
| 4585 | PHP | 8년 전 | 2159 | ||
| 4584 | PHP | 8년 전 | 2411 | ||
| 4583 | PHP | 8년 전 | 2354 | ||
| 4582 | jQuery |
프로그래머7
|
8년 전 | 1425 | |
| 4581 | jQuery |
프로그래머7
|
8년 전 | 1373 | |
| 4580 | jQuery |
프로그래머7
|
8년 전 | 1905 | |
| 4579 | PHP | 8년 전 | 2229 | ||
| 4578 | PHP | 8년 전 | 1740 | ||
| 4577 | PHP | 8년 전 | 2470 | ||
| 4576 | OS |
프로그래머7
|
8년 전 | 2697 | |
| 4575 | PHP | 8년 전 | 1924 | ||
| 4574 | PHP | 8년 전 | 1558 | ||
| 4573 | PHP | 8년 전 | 1966 | ||
| 4572 | PHP | 8년 전 | 2063 | ||
| 4571 | PHP | 8년 전 | 2415 | ||
| 4570 | PHP | 8년 전 | 2273 | ||
| 4569 | jQuery |
프로그래머7
|
8년 전 | 1864 | |
| 4568 | jQuery |
프로그래머7
|
8년 전 | 1402 | |
| 4567 | jQuery |
프로그래머7
|
8년 전 | 1967 | |
| 4566 | jQuery |
프로그래머7
|
8년 전 | 1897 | |
| 4565 | jQuery |
프로그래머7
|
8년 전 | 1648 | |
| 4564 | PHP | 8년 전 | 2578 | ||
| 4563 | PHP | 8년 전 | 1917 | ||
| 4562 | PHP | 8년 전 | 2426 | ||
| 4561 | jQuery |
프로그래머7
|
8년 전 | 1363 | |
| 4560 | jQuery |
프로그래머7
|
8년 전 | 1903 | |
| 4559 | jQuery |
프로그래머7
|
8년 전 | 1449 | |
| 4558 | node.js |
|
8년 전 | 3431 | |
| 4557 | jQuery |
프로그래머7
|
8년 전 | 1727 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기