in reply to progress bar

The general concept is outlined very well in Watching long-running processes through CGI.

My suggestion is that you read this article and then implement it.

As you don't tell us where exactly you have problems, my suggestion is to first eliminate all the Javascript from your approach and implement the solution in the linked post. After you got that working, you can easily add Javascript again to update parts of your page instead of reloading the complete page.