views:

359

answers:

3

Hi All,

We've got an ajax request that takes approx. 30 seconds and then sends the user to a different page. During that time, we of course show an ajaxy spinner indicator, but the browser can also "appear" stuck because the browser client isn't actually working or showing it's own loading message.

Is there an easy way to tell all major browsers to look busy with a JS command?

Thanks, Chad

A: 

jquery?

$('html').ajaxStart(function() { $('#busyindicator').show(); } );
$('html').ajaxStop(function() { $('#busyindicator').hide(); } );

But maybe I'm not understanding your question. what does 'look busy' mean ? Do you mean get the browser's progress bar or native busy indicator active? Don't think you can do that...

Scott Evernden
It sounds to me like he's already doing something similar and wants more, for example like you described setting the browser's native busy indicator.
Josh
Thanks Scott! Sorry for not being clear. Yup using Ajax and will try the post solution.
Chad
+2  A: 

Do you need to use AJAX in this situation? Could you instead post/put to another page whose whole purpose is to process the request and once finished redirect to the destination page?

You could still use some JS to pop the spinner, and since you're posting to another page, the brower will display its "native busy indicator". The browser should never show the middle page, once the request has been processed the response gets redirected to the destination.

BStruthers
Cool - yes this may be the best way to get the native indicator - actually make it work through a post.Thanks I'll change a few things around.
Chad
A: 

You could set the CSS cursor property of body to 'wait'. With prototype this would be like:

$(document.body).setStyle({cursor: 'wait'});

I believe this is the jQuery code, someone please correct me if I'm wrong as I am not a jQuery expert:

$("body").css("cursor", "wait");

This will make the entire page show an hourglass mouse cursor on Windows and a spinning watch cursor on Mac OS.

Josh
Ya this is a good idea also.... would be a quick alternative to actually posting the request to get the real native indicator.Thanks Josh.
Chad