PHP + JQuery / AJAX - loader with percentage

I have an external application in which I call a PHP script (lets call it script.php), which takes some time to complete. I want to show (on the client side) the percentage is completed.

In the script.php file, I can calculate the percentage of completed tasks at any time. I was looking a bit, and a possible solution should be:

  • On the client side, call the script.php file
  • Run a polling operation using another php script to get a percentage of script.php
  • Display this percentage on the client side.

My problem is how do I get and "share" this percentage between the script and another php file for display on the client side.

What options do I have with jQuery / AJAX (I tried to avoid using cached solutions).

thanks

+4
source share
1 answer

All you need on the client side is a javascript function that periodically calls your progress.php script or whatever it calls, and get the last percent. Then you can update the DOM with this value.

Take a look at this topic.

jQuery Poll AJAX for JSON response, processing based on AJAX result or JSON content

+6
source

Source: https://habr.com/ru/post/1396315/


All Articles