1

I'm new in jquery. I've two PHP scripts. first script accepts user input using form and when click on submit button then second script process user input by calling multiple API's.

Which take time to call API and get response. So i want to show progress bar with percentage till script getting process. So user knows that process is going on and wait till page get load.

Would anyone please help me to fix this. Thanks in advance.

3
  • Atleast share some of your code, no one is going to code for you, test it for free here, questions are asked to resolve doubts not to feed you. Commented Feb 3, 2018 at 4:32
  • You'll have to calculate progress in your PHP function somehow so the progress bar can be updated. Can you show an example of your PHP functions? Commented Feb 3, 2018 at 4:33
  • 1
    Possible duplicate of How to show progress bar with jQuery? Commented Feb 3, 2018 at 7:28

2 Answers 2

1

I don't think it is a good idea. Becoz jquery is slowing down your browser.

.progressbar{
width:100%;
height:4px;
background:blue;
}
.progressbar-loaded{
height:4px;
background:red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="progressbar"><div class="progressbar-loaded"></div></div>

<!-- your php codes going -->

end of my first php code<br>

<script type="text/JavaScript">
  $('.progressbar-loaded').css({width:'25%'});
</script>

<!-- your php codes going -->

end of my second php code<br>

<script type="text/JavaScript">
  $('.progressbar-loaded').css({width:'50%'});
</script>

<!-- your php codes going -->

end of my third php code<br>

<script type="text/JavaScript">
  $('.progressbar-loaded').css({width:'75%'});
</script>

<!-- your php codes going -->

end of my fourth php code<br>

<script type="text/JavaScript">
  $('.progressbar-loaded').css({width:'100%'});
</script>

this is the main process of progressbars

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

2 Comments

is there any way to calculate percentage dynamically. is the any way to know what time take my script to get fully execute in PHP? so i'll calculate % using it.
@Rajesh I dont think it is possible.
0

You can use loader or bootstrap progress bar https://www.w3schools.com/bootstrap/bootstrap_progressbars.asp

2 Comments

Thanks for your reply, I want to add it dynamically, how to add it and how to calculate percentage of execution
for that you can use js and css w3schools.com/howto/howto_js_progressbar.asp

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.