为什么使用Ajax的浏览器会卡住?

我们收到了一个约30秒的ajax请求:将用户转到另一个页面。在此期间,我们会显示一个ajaxy旋转器指示器,但是浏览器也可能“出现”卡住的情况,因为浏览器客户端实际上并没有工作或显示自己的加载消息。 有没有一种简单的方法来告诉所有主要的浏览器来使用JS命令呢? 谢谢!

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...

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.

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.