Progress bar in web system

0

Does anyone know a way to make a progress bar in web system? In case my progress bar is not for file upload, it is a task that takes a while, there it would be nice a progress bar so the user does not think it crashed. I already researched everything, but I did not succeed. In case my system is in PHP, but I think there is no way to do this in PHP, because in PHP I can not read the status of a request while it does not finish. I thought maybe I could do this in NodeJS, but I have no knowledge at all at node at the moment. Can anyone tell me if it would be possible with Node and where to start?

    
asked by anonymous 24.03.2017 / 14:30

2 answers

1

Frames,

Your question is very general, I do not know how it is structured, but to follow the progress of sending a file you can use something like this:

var formData = new FormData();
var arquivo = document.getElementById('arquivoParaEnvio').files[0];
formData.append('arquivoParaEnvio', arquivo);
var xhr = new XMLHttpRequest();

xhr.open('post', '/uploadURL', true);

xhr.upload.onprogress = function(e) {
  if (e.lengthComputable) {
    var progresso = (e.loaded / e.total) * 100;
    console.log(progresso + " %");
  }
};

I do not know if this is the case, but there is the node-upload-progress which is a Node.js module to manage upload and its progress: link

Here is a complete example of using the module:

There is also an express-upload-progress javascript library that manages upload progress and is styled with Bootstrap: link

    
24.03.2017 / 15:19
0

It is not for file upload, it is to update the progress of a request that takes too long. I got it sorted out. But for the record, the idea was to get the status of a request that takes a lot for the user to know what is happening. For this I write in the session how much of my task has already been processed and put an ajax to be called every 5 seconds for example. The logic was already set up, but I was locking the ajax because I was keeping the session open. So I figured out that I just closed the session with session_write_close () after writing the data that ajax does not hang anymore.

Thank you guys.

    
18.04.2017 / 15:44