0

I generate about 150 invoices in a php foreach loop (with dompdf class). This takes about 40s for the page/rendering to finish so I'm wondering if I can I place a bootstrap progress-bar before the foreach loop starts and inside this php foreach loop the width of this progress-bar should be incremented.

Is this possible? With jquery?

<div id="foo" class="progress progress-striped active">
  <div class="progress-bar" style="width: 1%"></div>
</div>
1

1 Answer 1

2

Here you have a good example about how to implement progress bar by PHP.

Here is the technique.

Create at least one div element with a certain width in your HTML document for displaying the progress bar.

Estimate the progress percentage in your PHP script. This number will be used to determine the progress bar's length.

"Echo" the Javascript for updating the content of div element above with a div that the width percentage is same as the calculated progress. Also give the div a different background color or background image so we can see it.

"Flush" it to the browser.

Sign up to request clarification or add additional context in comments.

2 Comments

This works in a "naked" test site. But on the invoice generating php file the progressbar stays on 1% the whole time and when the invoice rendering (php foreach loop) is done the progress-bar switches to 100% immediately
update I think it works now! I had $(function() { jscode } this didn't work. But when I only write the jscode in the foreach loop (without that $(function() beginning) it works!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.