mvFinishItUp()
当满足两个条件时,我需要执行特定的功能。更具体地说,一个条件是回调成功,$.ajax
另一个是正常的代码流,直到它到达函数。有点像这样:
$.ajax({
url: mv_finalUrl,
success: function (data) {
mvFinishItUp(data);
},
dataType: 'html'
});
/* here a lot more code, with animations and some delays */
mvFinishItUp(data) {
/* My function code */
/* But this code must only run after it has been called via the call back
and after all the other code has been ran as well */
}
因此,如果 ajax 回调更快,或者相反,函数必须等待所有代码。关于如何实施的任何想法?
我愿意改变脚本代码的整个概念,因为我相信 ajax 和函数本身之间的松散代码也应该转到函数......