私のコードでは、関数が非同期かどうかをテストし、非同期の場合はコールバック関数を使用したいと考えています。しかし、そうでない場合は、次の関数を手動で呼び出すだけです。関数が非同期かどうかをテストする方法はありますか? そうでない場合、すべての非同期 jQuery 関数のリストはどこにありますか?
if (isAsynchronous(fn)) {
args.push(function () { alert('callback!'); });
this.fn.apply(this, args);
} else {
this.fn.apply(this, args);
alert('synchronous');
}
それが不可能な場合は、リストを作成することが次善の策です。
var asynchs = {
animate: true,
fadeIn: true
//etc...
};
if (asynchs[fn]) {
args.push(function () {alert('callback!'); });
this.fn.apply(this, args);
} else {
this.fn.apply(this, args);
alert('synchronous');
}