PDA

View Full Version : Progress Bar - Help Needed



renganathan
3 Jan 2012, 1:35 AM
Hi All,

I want to show progress bar for ajax request. The response may come in 5 seconds or 19 seconds or any time.

How to show dynamically based on the response time.

Note:(Response time is keep on changing)


Please suggest solutions to achieve this

mitchellsimoens
3 Jan 2012, 6:15 AM
How are you going to know how long an Ajax call will take?

renganathan
3 Jan 2012, 8:36 PM
i just run javascript timer. Every 5 seconds i am checking response has came or not

skirtle
3 Jan 2012, 10:52 PM
Any reason why you're not using the callbacks on the Ajax request to hide the progress bar?

Checking every 5 seconds sounds painful. Why 5 seconds? That seems much longer than necessary.

If your requests takes 19 seconds to complete it sounds like you may have bigger issues. Large uploads or downloads can justify such a long response time but if the time is spent processing on the server then you might want to consider a more asynchronous approach to handling your requests. Keeping a connection open for upward of 19 seconds sounds like a scaling disaster waiting to happen. Just because the server takes 19 seconds doesn't mean the request has to hang for 19 seconds before responding. Instead you can respond immediately and then poll the server periodically to get the current progress.

This might be overkill in your scenario but it's something you may want to consider.