Skip to content Skip to sidebar Skip to footer

Show Progress During A Long Ajax Call

I have a simple web site (http://www.kousenit.com/twitterfollowervalue) that computes a quantity based on a person's Twitter followers. Since the Twitter API only returns follower

Solution 1:

For more-or-less-accurate progress reporting you have two alternatives:

  • Keep the server telling you its progress
  • Keep the client (browser) asking the server about its progress

Keeping the server telling you the progress would be kind of easy to implement. You can, instead of calling the Ajax.Updater, create an iframe element and modify the server to, for each iteration, dump a response with some javascript to trigger showing the progress on the browser, and to flush that response. Like that, the browser will execute the javascript and keep waiting until the response finishes, so the user will see the progress indicator moving up until everything's completed.

Other approaches are available for the server to tell you about the operation's progress. You can Bing/Google about Comet servers.

As for getting the browser to periodically ask about the operation's progress, you can either return some token to the browser for each iteration that the browser would check to see if it's the final result or if it should pass it on to the server so the server keeps hitting twitter for the next result set, or somehow keep a state (if you have session state support, that might do it) in your server that is updated in each iteration and that can be polled on a separate request.

I hope the suggestions help.


Post a Comment for "Show Progress During A Long Ajax Call"