Friday 15 January 2010

javascript - Append output after each loop on an ajax call back function -



javascript - Append output after each loop on an ajax call back function -

it's been more 2 hours trying find optimal way display result rendered ajax phone call function , allow me explain want improve understand ...

i have button "send" , on click event defined function sends $category_id page , grab recipients database , send each email. whole process working fine , after each loop :

(foreach ($recipients $recipient)) {send_mail(); echo "email sent ....";}

i'm returning echo statement telling email correctly sent recipient . javascript function defined append echo results in div , instead of displaying every statement after getting rendered , gathers them , display them @ 1 time .

$.ajax({ async: true, url: 'send_emails.php?category='+category, success: function(r){ $('#status').append(r); //this happens @ 1 time } });

is there improve thought reach goal ?

thanks in advance

the success event of ajax called triggered when xhr status changes 200 (successful). happens when back-end done processing.

what need check xhr readystate attribute. set '3' during processing of request. can send updates php script webpage.

here blog explains how it

javascript php ajax asynchronous

No comments:

Post a Comment