gpt4 book ai didi

jquery - ajaxStop 函数内部如何工作?

转载 作者:行者123 更新时间:2023-12-01 04:36:16 25 4
gpt4 key购买 nike

如果这不是提问的合适地方,我很抱歉。

我根据 documentation 确定知道ajaxStop() 函数的以下功能:

Whenever an AJAX request is completed, jQuery checks whether there are any other outstanding AJAX requests, if there are no requests remaining, then jQuery triggers the ajaxStop event.

我似乎无法理解的是它内部是如何做到这一点的。它如何知道所有ajax请求都在页面中结束了?

最佳答案

有一个全局ajax计数器jQuery.active

每个请求在开始时都会递增,在完成时递减。

如果完成时为零 ajaxStop被触发

这是line in the source触发它

关于jquery - ajaxStop 函数内部如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53481664/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com