Chrome浏览器对AJAX页面加载的原因和QUOT;忙碌光标"保持 [英] Chrome AJAX on page-load causes "busy cursor" to remain

查看:136
本文介绍了Chrome浏览器对AJAX页面加载的原因和QUOT;忙碌光标"保持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在谷歌浏览器,AJAX在$称为(函数(){...});似乎保持页面加载。

In Google Chrome, AJAX called within $(function(){....}); seems to keep the page loading.

我有一个网站用了几页用标签。因为我使用的是廉价的GoDaddy的主机,我想在页面加载尽可能快。因此,我想加载一个页面上1选项卡,然后在后台使用AJAX来加载其他选项卡。当我从运行AJAX

I have a site with a few pages with tabs. Because I'm using cheap godaddy hosting, I want the page to load as fast as possible. I thus want to load a page on 1 tab and then in the background use AJAX to load the other tabs. When I run AJAX from

$(function(){
    /*AJAX CODE HERE */
});

的光标显示在网页作为装载了很长时间( http://jsfiddle.net/mazlix/7fDYE/9/

我已经想出了一个办法(在Chrome ATLEAST)有所修复,使用的setTimeout(); http://jsfiddle.net/mazlix/7fDYE/8/ ),但这只是工作,如果你正确地$当窗口完全负荷P,$ pdict,显然使得它走更长的时间来加载。我想办法在页面加载后立即加载通过AJAX的内容,所以没有忙光标显示在等待返回的AJAX。

I have figured out a way (in chrome atleast) to somewhat fix that using setTimeout(); (http://jsfiddle.net/mazlix/7fDYE/8/), but this only works if you correctly predict when the window finishes fully loading and obviously makes it take longer to load. I want a way to load content via AJAX immediately after the page loads, so no "busy-cursor" is displayed while waiting for the returned AJAX.

推荐答案

谷歌浏览器显示正在加载指示灯,只要没有新的查询服务器。当负载指标显示,所有新的请求都导致Chrome浏览器扩展指示器显示的时间。此外,当 ESC 是pssed时,指示器显示$ P $,所有的请求都将立即中止!这些措施包括AJAX请求甚至Flash的要求!看看<一href="http://stackoverflow.com/questions/6015496/how-does-youtube-control-flash-content-loading-chrome-12">this问题:我认为这是由于YouTube的,但结果却是Chrome的惯常行为

Google Chrome shows Loading Indicator as long as there are no new queries to servers. While the loading indicator is shown, all new requests are causing Chrome to extend the time the indicator is shown. Furthermore, when esc is pressed while the indicator is shown, all requests are aborted! These include AJAX requests and even Flash requests! Take a look at this question: i thought it was because of Youtube, but it turned to be Chrome's usual behavior.

要避免延长的时间加载指示器所示,使得负载指示后请求的唯一方法是隐藏:即当所有查询服务器完成。在 .load() jQuery的文档说:

The only way to avoid "extending" the time Loading indicator is shown, is making the requests after the loading indicator is hidden: i.e. when all queries to server are completed. JQuery's documentation on .load() says:

负载事件被发送到一个元素时,它与所有的子元件已经完全加载。这个事件可以被发送到的URL相关的任何元素:图像,脚本,框架,内置页框,窗口对象

The load event is sent to an element when it and all sub-elements have been completely loaded. This event can be sent to any element associated with a URL: images, scripts, frames, iframes, and the window object.

因此​​,如果你相信有您的网页上只有图片,脚本和框架, window.load()将被解雇只是当你需要它。添加的setTimeout()来,将工作,只要你喜欢。这里有一个例子: http://jsfiddle.net/7fDYE/22/

So, if you're sure that there are only images, scripts and frames on your page, window.load() will be fired just when you need it. Adding setTimeout() to it will work as you like. Here is an example: http://jsfiddle.net/7fDYE/22/

如果有正在您请求之前,其他请求,您应该等待它们完成!例如,你知道,除了图像/脚本等,你的页面加载前3个AJAX请求。你可以有这样的事情:

If there are other requests being made before your request, you should wait for them to be completed! For example, you know that besides the images/scripts etc. you have 3 more AJAX requests before the page loads. You can have something like this:

var loaded=0,needsToBeLoaded=4; //3 AJAX + window
function onLoad(){
    loaded++;
    if(loaded==needsToBeLoaded){
         //do the AJAX request   
    }
}
window.load(onLoad);
// add onLoad() to all 3 AJAX request handlers

我不知道,你可以使用Flash的要求做...

I'm not sure what you can do with Flash requests...

这篇关于Chrome浏览器对AJAX页面加载的原因和QUOT;忙碌光标&QUOT;保持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆