How to display working in progress indication on the screen while processing in the background

Hi,

Can somebody help me?

Requirement:


Once a form is filled and submitted, I would be sending some emails in the background. While emails are being sent, I want to display some gif icon indicating "work in progress" status to the user. Once the emails are sent, I should be able to retrieve success/error messages and display them on the screen.


I have poor understand of ajaz. I just tried using Jbusy extension(from Yii extension repository) but it only alerts with static success/failure messages on the basis of success/failed ajax calls made to email processing controller URL. (doesn’t handle return status of controller function)

I wanted to pass custom messages from my email processing controller method back to main screen.

Kindly suggest me best way to achieve this functionality.

Thanks…!!!

I think, it is seldom one would display progress indicator while processing, because it will only make the server busier (must post the status value beside send emails). I think mostly we would only show the loading image…

If you want to showing the real progress indicator, then these might be the solution

in the client side(located in views file)

  1. using JavaScript setInterval() to keep sending ajax request to the server(let say ControllerA) to get the status

  2. the ajax result then update the progress bar…

in the controller (which names ControllerA)

  1. create an actionStatus() which echo the number of email sent.

I met the same problem. I agree it may make the server busier. However with it we make our website become much more friendly to users.

I think it is a good solution to use controller and ajax which is your suggestion. When I try to work it out, it becomes more difficult. For example, if we have a $count in our controller. We increase it as we handle more emails.

However, when ajax request comes, it would be handled by another instance of the controller class. So we just get 0 again, not the real progress.

Hope to get your suggestion on how to handle this situation. Last time I also asked a similar question in

this link.

TKS in advance.

Much more thanks if you have any examples.

Anyone knows? It is a little compicated. However, it is very important to build a user friendly system.

is this what you need?

http://thupten.veryusefulinfo.com/2011/07/20/progress-bar-to-display-servers-script-execution-using-jqueryjqueryui/

Thank you very much! That is the result I want.

In this article file is used by PHP to communicate with JS. PHP creates a file to record the progress. JS requests the file by Ajax and display it. Last time I tried this method. I also tried to use session, golbal variables and many other methods. I think displaying progress is comman request. I hope we could find a better way to do that.

We start a long function by Ajax. I just wonder if there is any way we could find the undergoing process. So we could get a higher performance.