Thursday, 15 January 2015

javascript - Display jquery response before php script complete execution -



javascript - Display jquery response before php script complete execution -

i have simple jquery code:

$(document).ready(function () { $(document).on('click', 'button', function(){ $.post('post.php', { test: 'yes' }, function(data, textstatus) { alert(data); }); }); });

and post.php page:

<?php /* stuff takes time */ echo '1'; ?>

so submit post request php page using jquery , want alert response 1 in above example. problem script takes sometime execute in homecoming slows downwards response.

this simplified example. there way response before total loading of php script? tried echo before rest of script doesn't matter response won't sent before script completes tasks.

you can seek flushing buffer.

javascript php jquery

No comments:

Post a Comment