0
のjQueryをdeffered。その後、警告文を実行した後。どうすればこのことができますか私を助けてください。はjQueryのは、決意を複数回
のjQueryをdeffered。その後、警告文を実行した後。どうすればこのことができますか私を助けてください。はjQueryのは、決意を複数回
使用$.when()
を解決する約束(Deferredの作り方)を待つには、ゼロ以上Thenableオブジェクト、非同期イベントを表し、通常は繰延オブジェクトに基づいてコールバック関数を実行するための方法を提供します。
$(document).on('click', '#Signup', function() {
console.log("Signup...");
$.when(email_check('Signup'), mobile_check('Signup'))
.done(function(){
console.log("All done!")
});
});
function email_check(Signup){
var d = $.Deferred();
setTimeout(function() {
\t console.log("email_check resolved");
\t d.resolve();
}, 1000);
return d;
}
function mobile_check(Signup){
var d = $.Deferred();
setTimeout(function() {
\t console.log("mobile_check resolved");
\t d.resolve();
}, 2000);
return d;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button type="button" id="Signup">Signup</button>
[ '$ .when()'](https://api.jquery.com/jquery.when/):_ "ベースコールバック関数を実行するための方法を提供on 0個以上のオブジェクトです。通常、非同期イベントを表すDeferredオブジェクトです。 "_ – Andreas
@Andreasはあなたに答えてください。私はあなたの言うことを理解することができます。 –