jQuery.ajax checking if there is already another xhr

Posted by digitalFresh on Stack Overflow See other posts from Stack Overflow or by digitalFresh
Published on 2010-06-18T05:05:28Z Indexed on 2010/06/18 5:13 UTC
Read the original article Hit count: 433

Filed under:
|
|
|

I have a page when, if the user is near the bottom of the page, loads the next page.

I just recently switched it to jQuery, and now use the jQuery.ajax() function to get the data. However, now i cannot check if the xhr is already loading, making the page load multiple xhrs when the user near the bottom.

My listener is:

$(document).scroll(function () {
            if(/* scrollbar is near bottom */)
            loadxhr(dat++); //function that calls jQuery.ajax()
        }
});

Basically, can you track the readyState of the call in a global scope?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery