I want to show progress with jquery ui progress bar when an ajax request fires and when it finishes. The problem is I don\'t know how to set values for the progress bar depe
I faced this situation in our company's in-house app. It was a critical app and we needed to show progress to the user. So, despite the fact that @Thilo mentioned about network traffic, we had to implement it so that the user could be informed when the long running process was finished and how it progressed over time.
We broke it down to small pieces.
Spawn a thread on the server-side code to run the particular process. For ASP.Net it was like this:
System.Threading.ThreadPool.QueueUserWorkItem(AddressOf MyProcessRoutine, objectParameter)
Within this "MyProcessRoutine" run your long-running code and update a static variable for counter or persist in database, for each step you want to monitor.
Create another function routine which keeps checking this counter and returns the current value. For example: Public Shared Function CheckStatus() As Integer
From your client-side code keep polling this routine say every 5 seconds (depending on how much network traffic you can afford and how much precision you want.
For example: timer = setInterval("MyWebService.CheckStatus();", 500);
In your client-side code, use this returned value (counter) to update your progress bar.
Besides just a counter, you can also return an object containing relevant details like record-id to show the user about where the process is currently at.
Make sure you handle the thread very carefully, handle all possible exceptions and have proper cleanup.