Hello, I need to add a loading animation to the function that works after clicking the button

here is the function itself

function get_revpopup_cart( product_id, action, quantity ) { quantity = typeof(quantity) != 'undefined' ? quantity : 1; if ( action == "catalog" ) { $.ajax({ url: 'index.php?route=checkout/cart/add', type: 'post', data: 'product_id=' + product_id + '&quantity=' + quantity, dataType: 'json', beforeSend: function(){ $('body').addClass('blur2'); $('#pagefader2').fadeIn(70); }, ............. 

here is the download animation < div class="page_gif_progress_icon"><div class="circle"></div></div>

button: <a onclick="get_revpopup_cart('103', 'catalog', '1');" data-toggle="tooltip" title="В корзину"><i class="fa fa-border fa-shopping-basket"><span class="prlistb">add in cart</span></i> <a onclick="get_revpopup_cart('103', 'catalog', '1');" data-toggle="tooltip" title="В корзину"><i class="fa fa-border fa-shopping-basket"><span class="prlistb">add in cart</span></i>

An animation should appear before $('body').addClass('blur2'); and the abyss after the function is executed

thank

    1 answer 1

     function get_revpopup_cart( product_id, action, quantity ) { quantity = typeof(quantity) != 'undefined' ? quantity : 1; if ( action == "catalog" ) { $.ajax({ url: 'index.php?route=checkout/cart/add', type: 'post', data: 'product_id=' + product_id + '&quantity=' + quantity, dataType: 'json', beforeSend: function(){ $('body').append('<div class="page_gif_progress_icon"><div class="circle"></div></div>').addClass('blur2'); $('#pagefader2').fadeIn(70); }, 

    And in the processing of the result add:

     $(".page_gif_progress_icon").remove(); 
    • Straight what you need! thank you so much! - Yury R