$(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