Page 1 of 1

Ideas for trasfering data from php to js

Posted: Fri Feb 11, 2011 4:48 pm
by fishown
Hello every one,
Program Backgound:
My program is basicly download huge files from anouther server over HTTP/FTP protocols,
As you can imagen this this action take some time, So I decide to add progress bar to this action.

So what I did so far (that by the way pritty lame):

Index.php - recive the address and has button to start or to reset the fields,
action.js - On click, get the address from the index and start "Progress.php" and read session file "info.php"
Progress.php - download the file using cURL and put the "percent" into session (that as i alredy mationd will be read by "action.js"

This mathod is pritty lame and week...
I Just want you peoeple to drop a new ideas that i could start from.

Thanks alot.

Re: Ideas for trasfering data from php to js

Posted: Fri Feb 11, 2011 6:29 pm
by Technocrat
Best bet would probably be with AJAX. Jquery has a pretty easy to understand and use library for AJAX and timed events. Just make an ajax file that simply gets the % from the session and passes back to your JS. Then update to the screen.

Re: Ideas for trasfering data from php to js

Posted: Fri Feb 11, 2011 6:43 pm
by Blackshawk
Either that or you could look into doing it with an iframe (aka: Comet style). This is similar to Ajax, except that you don't have to continuously poll the server.

http://www.zeitoun.net/articles/comet_and_php/start