I would like to know if it’s possible without javascript to update an echo ?
For example
<?php
for ($i = 1; $i < 100; $i++){
echo $i;
}
?>
But it will only update the number without adding another line, and another until 100. Is this possible or only with javascript you can achieve this.
I need to output a counter to know how much files is being processed at the moment like
45 of 100 pages
PHP is a server-side language. The script is requested, executed and then sent to the client.
JavaScript executes client-side only. Which means that it can send a request to a PHP script, but will always return the result of the script.
The only option is AJAX requests. Basically, you write a PHP script that moves one file at a time. JavaScript handles the loop from 1 to 100 and send 100 synchronous requests to the PHP script with different parameters. Then you can track the progress and update DOM elements on your HTML page.
jQuery has a nice .ajax() function that can get you started. Below is a quick example. It won’t work right off the bat but you can build on it to make it work.
PHP
JavaScript