jquery - Continuous status updates from a process using AJAX and PHP -


i've php script pushes large media files remote server via ftp. working smoothly. enhance , make report ajax client initiates transfers. basically, report below after each transfer:

1/12: file xbacd.dat has been copied /dir1/sub2/ - 2.2mb

2/12: file impact_analy.ppt not found in /var/www/files - resuming.

3/12: file abc_consult.doc has been copied /dir1/sub3/ - 8.2mb

ajax handler on other hand should displaying in div, , when arrives.

i had no luck following code, , hence switching on ajax.

    ob_start();      require_once 'init.php';      while(files){      // transfer code      // status     echo "$idx/$count: file $f has been copied $tar_dir - $s";      ob_flush;  flush;  } 

i'll tell did once, i'm no sure it's best solutions worked. should have iframe , set target of form iframe

<script> function showmsg(msg){    alert(msg); } </script> <form action="thecommandhandler.php" method="post" target="myiframe">   <input type="submit" value="do command" /> </form>  <iframe name="myiframe"></iframe> 

once posted thecommandhandler.php, should have line of code in php script:

echo "<script>parent.showmsg('$idx/$count: file $f has been copied $tar_dir - $s');</script>"; 

you can send many messages client , invoke showmsg function on parent document.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -