Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Poll the database from a web page? - ASP.NET

Tags:

.net

ajax

asp.net

Here's what I am trying to do. I have a website that lets users submit requests that are queued up in a Jobs table that the service picks up and processes. I have a status column in the table that denotes whether the request is queued up for processing or being currenty processed by the service or the service has completed processing the request. The entire process takes a few minutes.

I have a Status ASP.NET page in which I will need to show the current status of their request on a real time basis. I want to display some kind of animation and denote the current status. One way I could do this is to have a meta http refresh every x seconds that checks the status of the request (I guess this is how sites such as Expedia, Priceline does it?)

I would like to prevent a complete page refresh is possible and looking for a AJAX/JQuery solution. How would I implement this? Is polling the correct approach?

like image 838
Nick Avatar asked Oct 14 '22 11:10

Nick


1 Answers

Polling via AJAX is the easiest and simplest for your needs. If you know the upper and lower bounds on the time it will take then I'd probably just have the animation run for that length of time and then do something for the exceptional case.

Others have done the same:

See: http://news.ycombinator.com/item?id=946165 and http://www.chrisharrison.net/projects/progressbars/ProgBarHarrison.pdf

like image 103
Rodrick Chapman Avatar answered Oct 18 '22 11:10

Rodrick Chapman