1

how can I show the loader only on my div and not on the body during an ajax call ?

Can't make it work.

Here's my code, I have the show loader and the context but I'm missing something ?

<div id="divDate">
     <span id="SpanNonSticky"></span>
</div>

<script>
    require([
            'jquery',
            'mage/template',
            'jquery/ui',
            'mage/translate'
        ],
        function($)
        {
            "use strict";
            console.log(" ====== date.js is loaded ====== ");
            $(document).ready(function()
            {
                $('#divDate').trigger('processStart');
                let id = "<?php echo $this->getCustomer()->getData("id"); ?>" ;
                setTimeout(function(){
                    $.ajax({
                        context : $('#divDate'),
                        showLoader: true,
                        url: "<?php echo $block->getUrl('my/url/date'); ?>",
                        type: "POST",
                        data: {id:id},
                        dataType : "json",
                    }).done(function (response) {
                        console.log(response);
                        $('#SpanNonSticky').html(response);
                        return true;
                    });
                },8000);

            });

        });

</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.