简体   繁体   English

如何在Jquery中停止对此函数的调用?

[英]How do I stop the call to this function in Jquery?

Issue: 问题:

I am calling a function on scroll in my code: 我在代码中滚动调用一个函数:

$(window).bind('scroll',function (){
    loading();
});

Here loading() is sending an Ajax request to load the pages, now I want to stop the call to this function when my total_pages count is equal to current_page or else it is sends too many Ajax requests. 在这里loading()正在发送一个Ajax请求来加载页面,现在我想在我的total_pages计数等于current_page时停止对该函数的调用,否则它将发送太多的Ajax请求。

Question: 题:

How do I stop the call to this function in Jquery? 如何在Jquery中停止对此函数的调用?

You can use the unbind method to remove the scroll handler from window . 您可以使用unbind方法从window删除scroll处理程序。 Try: 尝试:

$(window).unbind('scroll');

It should do the trick 它应该可以解决问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM