我的设置
function ajaxLoadSth(value, attribute) {
$.post( url, value, function(response) {
// interpreting the response
var foobar = $('#foo') + $('.bar').find('.sth');
// print interpretation into DOM
container.append(foobar);
// do some funky stuff
doSomeFooWithDom();
checkSomeBarHere();
updateSomeValuesThere();
// now call the function again with different values
// THIS IS WHAT MY QUESTION REFERS TO **************
if ( true ) {
ajaxLoadSth(newValue, newAttribute);
}
});
}
我的问题
该函数不能在// do some funky stuff -part,一些 DOM 操作,完成执行之前调用自己-但它确实如此。
我的问题
- 这是为什么?是因为那些“时髦的东西”位于外部函数中吗?这对同步执行有影响吗?
- 我怎样才能让“自己调用”等到上面的东西完成?
我已经考虑过通过设置全局变量和触发处理程序来告诉它们准备好的函数。每次触发处理程序时,一个函数都会检查所有变量是否设置正确,然后执行函数调用。那个怎么样?
非常感谢您提前抽出时间!