How to cancel/abort jquery ajax request

Posted by user556673 on Stack Overflow See other posts from Stack Overflow or by user556673
Published on 2010-12-29T03:04:44Z Indexed on 2010/12/30 5:54 UTC
Read the original article Hit count: 416

Filed under:
|
|

I've an ajax request which will happen in every 5 seconds. But the problem is before the ajax request if the previous request is not completed I've to abort that request and make a new request.

My code is something like this, how to resolve this issue?

$(document).ready(
    var fn = function(){
        $.ajax({
            url: 'ajax/progress.ftl',
            success: function(data) {
                //do something
            }
        });
    };

    var interval = setInterval(fn, 500);
);

Thank you.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX