The difficult part of this idea is that while Ajax is asynchronous and happening in the background, it's still working against the standard HTTP protocol. You send a request to the server and wait an unknown time until the response comes back.
In order to build something that provides progress you'd have to do several things:
- Spin off a thread to do your background work so the initial call is not blocked.
- Maintain knowledge of that thread (i.e. persist a thread ID in user session or similar)
- Provide some mechanism on an object in that thread context for accessing progress (possibly difficult with a SQL call, depending on what you are doing in SQL it might be easier or harder)
- Change your client code behavior from a single AJAX call to run the process, to a call that starts the process, then sets up a timer for status polling.
-Peter
compiledthoughts.com