Change based on comments.
If you want to keep track of how many of your messages have been downloaded, you need to make a polling system in the current session (you can do with sockets, but it gets harder).
In PHP, start a session (before loading the first page) and create a session variable to save progress. On the page you are posting, use the same session, set the progress to 0, and each time SendMessage loops, update this variable with the latest achievement.
In JS, send the PHP request using AJAX (so that the HTML remains) and then use setTimeout() to execute the second AJAX request to the new file you need to write, which uses the same session, captures the updated progress data and returns him - it will be the same as the original answer. When you get the answer, repeat setTimeout and repeat (do not use setInterval , as you may crash the server doing this). When the original request returns, kill the timeout.
Final note: using jQueryUI for this is unnecessary; therefore, use it only if you have other material for which you are using it. Otherwise, it is 10 lines of code (below).
Hope this helps / answers the question.
** Previous answer **
The easiest way to do this is to wrap two divs inside each other.
Your stylesheet should contain:
<style> .progressBar { position: relative; border: 1px solid black; } .progressIndicator { position: absolute; left: 0; top: 0; width: 0; height: 10%; background: #f00; } </style>
Your HTML should contain
<html> <div class="progressBar"> <div class="progressIndicator"> </div> </div> </html>
Your javascript (jQuery) answer should contain
$('.progressIndicator').css({width: parseInt(data, 10) + "%"});
(where data is the value returned between 0 and 100)