最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Active AJAX requests - Stack Overflow

programmeradmin3浏览0评论

Prototype stores the number of active AJAX requests in Ajax.activeRequestCount. Is there something similar in jQuery/Mootools etc or something that can be used from XMLHttpRequest?. Ideally I need a library independent method of detecting the number of active AJAX requests within a page. If not, a method for each library would suffice.

Prototype stores the number of active AJAX requests in Ajax.activeRequestCount. Is there something similar in jQuery/Mootools etc or something that can be used from XMLHttpRequest?. Ideally I need a library independent method of detecting the number of active AJAX requests within a page. If not, a method for each library would suffice.

Share Improve this question edited Dec 28, 2011 at 20:32 Rob W 349k87 gold badges807 silver badges682 bronze badges asked Dec 23, 2009 at 9:34 robjmillsrobjmills 18.6k16 gold badges80 silver badges123 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 2

Prototype only keeps track of the number of active requests made using Prototype APIs. If you were to make an AJAX request using any other method, Ajax.activeRequestCount will not be affected. There is no cross-library way to keep track of every request made, unless you were to keep track of them yourself.

$.active for jQuery, as I see from the documentation

MooTools doesn't seem to have one (here's the Request class source)

Perhaps for MooTools you could make an intermediary function to call Ajax, and make your own count there?

Mootools request objects are initiallized once and resused, you can keep count when initializing.

BTW, I bet that the reson you want to keep this counted is not a requirement with mootools, due to its single instance structure, look into it!

jQuery has an (undocumented?) ajax active counter: jQuery.active

Roger Hu has a blog post about it.

发布评论

评论列表(0)

  1. 暂无评论