function called on scroll event
===

I am calling a function on scroll like this

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

and my loading() is sending Ajax request to load next 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 sending too many Ajax requests.

Please help as to how we can stop the call to this function.

Thanks in advance!!