Javascript $when.then()执行的jQuery序列
我试图按特定的顺序执行函数,但在理解Javascript $when.then()执行的jQuery序列,javascript,jquery,Javascript,Jquery,我试图按特定的顺序执行函数,但在理解$.when()时遇到了问题 函数x(){ def=$.Deferred(); $.when(def).then(console.log(def.state()); } x() 然后需要回调,因此您应该创建一个wrap函数: function x() { def = $.Deferred(); $.when(def).then(function(){ console.log(def.state()) }); } x(); 然后需要回调,
$.when()
时遇到了问题
函数x(){
def=$.Deferred();
$.when(def).then(console.log(def.state());
}
x()代码>
然后
需要回调,因此您应该创建一个wrap函数:
function x() {
def = $.Deferred();
$.when(def).then(function(){
console.log(def.state())
});
}
x();
然后
需要回调,因此您应该创建一个wrap函数:
function x() {
def = $.Deferred();
$.when(def).then(function(){
console.log(def.state())
});
}
x();
第一:您应该解决您的差异
。第二:您应该将函数传递给,然后传递给方法
函数x(){
def=$.Deferred().resolve();
$.when(def).then(函数(){
console.log(def.state());
});
}
x()代码>
首先:您应该解决您的差异问题。第二:您应该将函数传递给,然后传递给方法
函数x(){
def=$.Deferred().resolve();
$.when(def).then(函数(){
console.log(def.state());
});
}
x()代码>
解释为什么可能有用。解释为什么可能有用。