I am using jquery ajax load() function to refresh DIV content every 5 sec. But, after sometime multiple xhr request pending and slow down the process to freez browser! How to abort those pending request after waiting 5 sec/request. Or any better solution to fix this issue?
    $(document).ready(
    var xhr;
    var fn = function() {
        if (xhr && xhr.readyState != 4) {
            xhr.abort();
        }
        xhr = $.ajax({});
    };
    var interval = setInterval(fn, 5000);
);
Some developer talking about above mentioned code block but i could not fix my problem with it.
HERE IS MY CODE :
$(document).ready(function() {
    $('.slot1_clicker').on('click', function() {
        $("#slot1").load(" #slot1 ", function() {
            $.getScript("/files/po.js");
        });
    });
});
setInterval(function() {
    $('.slot1_clicker').trigger('click');
}, 5000);
