A
A
advancesss2019-08-02 09:15:41
AJAX
advancesss, 2019-08-02 09:15:41

How to display a graphic loader when autoloading content?

Hello, there is a script that, when scrolling down, loads data on ajax. Can you please tell me how to display the loader in gif or svg format that would be displayed when loading data?
thanks for the help

$(function() {
    var load_more = false;

    $(window).scroll(function() {
        if($("#ajax_next_page").length && !load_more) {
            var url = $("#ajax_next_page").attr("href");
            var offset_button = $("#ajax_next_page").offset();
            if($(this).scrollTop() >= offset_button.top - $(window).height()) {
                load_more = true;
                $.ajax({
                    url: url,
                    type: "POST",
                    data: {IS_AJAX: 'Y'},
                    success: function(data) {
                        $("#ajax_next_page").after(data);
                        $("#ajax_next_page").remove();
                        load_more = false;
                    }
                });
            }
        }
    });
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question