0
我试图按照特定的顺序执行函数,但是当涉及到理解$.when()
时,我遇到了问题。
function x() {
def = $.Deferred();
$.when(def).then(console.log(def.state()));
}
x();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
我的理解是,当def
得到解决,则console.log(def.state())
应该执行。换句话说,执行x()
后不应得到任何回应,因为def
是pending
?
解释为什么可能会有所帮助。 – Adam