470,594 Members | 1,560 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,594 developers. It's quick & easy.

AJAX Progress bar

I am working on a servlet that takes fairly long to process, and I
would like to keep the user updated on the progress with a status bar.

I have already finished the necessary javascript and servlet code: The
local script regularly polls the servlet, which uses the session to
check on the progress of the other program and reports back with an
XML file. The local script then updates the progress bar as necessary.

This works nicely until I actually place it into a form. Apparently,
submitting a form and "leaving" the current page in the browser
somehow suspends the Javascript until the new page is built, which
means that nothing happens while the servlet result page is loading.
How can I make the progress bar script run until the server actually
sends a response to my form submission, and the page is rebuilt?
Feb 12 '08 #1
1 2561
SAM
Arancaytar a écrit :
I am working on a servlet that takes fairly long to process, and I
would like to keep the user updated on the progress with a status bar.

I have already finished the necessary javascript and servlet code: The
local script regularly polls the servlet, which uses the session to
check on the progress of the other program and reports back with an
XML file. The local script then updates the progress bar as necessary.

This works nicely until I actually place it into a form. Apparently,
submitting a form and "leaving" the current page in the browser
somehow suspends the Javascript until the new page is built, which
means that nothing happens while the servlet result page is loading.
How can I make the progress bar script run until the server actually
sends a response to my form submission, and the page is rebuilt?
a gif-anim ? showed/hidden when necessary.
function progressBar(yesNo) {
if(yesNo)
myBar = setInterval(function(){$('bar').innerHTML += '+';},300);
else { clearInterval(myBar); $('bar').innerHTML = '';}
}

function queryHttpRequest ( url, argts ) {
progressBar(true);
http_request = new ... blah

if(http_request) {
blah
http_request.onreadystatechange = function() {
progressBar(false);
blah ...
};
blah ...
}
}

Really the JS waiting bar is blocked during the request ?
I can't test because I havn't slow requests.

--
sm
Feb 12 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by mattdaddym | last post: by
1 post views Thread by Mike P | last post: by
3 posts views Thread by Ken1 | last post: by
16 posts views Thread by deostroll | last post: by
1 post views Thread by gamernaveen | last post: by
5 posts views Thread by =?Utf-8?B?SmFzb24gSGFydHNvZQ==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.