$(document).ready(function() {
$('.out').each(function(index) {
.ajax({
url: "php,
type: "GET",
success: function(data) {
// LOOP each dynamic textbox for my specific validation
console.log('1'); // flag if any error
}
});
// I though this will run after $('.out').each()
console.log('2'); // my plan is to check if atleast 1 error occur
});
result:
> 2
> 1
> 1
> 1
instead of:
> 1
> 1
> 1
> 2
我认为这个流程是先运行每个函数先显示1 1 1等,然后它会显示2.任何人都可以帮助我如何完成我所需要的?jquery执行行为
在此先感谢
你到底需要什么? – 2012-08-01 02:58:09
无法复制,我得到'1 1 1 2'。 – Musa 2012-08-01 02:58:45
哦对不起,我忘了一些东西,我已经添加了我的ajax,然后把console.log(1)放在ajax里面。也许ajax有一些延迟,脚本不会等待ajax完成。我不确定 – Paengski 2012-08-01 03:01:22