Lj Pearson Lj Pearson - 3 months ago 10
HTML Question

Is there a way to determine if a specific ajax is still running?

I have a few ajax running on my sites simultaneously with setInterval, and there are some with buttons,

so for example if I want to check if this was finished, before I run it again. cause everytime I scroll to the bottom I run this. What is the best way to know that It should not call this, will still it still running.

$.post(base_url+"index.php/contracts/getleftpanedocs", {},
function(data){

if(data.count > 0){
$("#spandocdisplaycount").html(data.count);
$("#divdocsdisplay").fadeIn("slow");
}else{
$("#spandocdisplaycount").html(data.count);
$("#divdocsdisplay").fadeOut("slow");
}
},"json");

Answer

You can probably set a flag

loading = false;
if(!loading){
    loading = true;
    $.post(base_url+"index.php/contracts/getleftpanedocs", {},
        function(data){
           loading = false;
        }
}

something like that might work!

Comments