Show “loading” animation on button click

前端 未结 6 942
感情败类
感情败类 2021-01-30 14:10

I want to do something very simple. I have one button in my page.

6条回答
  •  被撕碎了的回忆
    2021-01-30 14:32

    The best loading and blocking that particular div for ajax call until it succeeded is Blockui

    go through this link http://www.malsup.com/jquery/block/#element

    example usage:

     
    

    script

    jQuery.ajax(
    {   
     url: site_path+"/restaurantlist/addtocart",
     type: "POST",
     success: function (data) {
       jQuery("#id").unblock(); 
    },
    beforeSend:function (data){
        jQuery("#id").block({ 
        message: jQuery(".smallLoader").html(), 
        css: { 
             border: 'none', 
             backgroundColor: 'none'
        },
        overlayCSS: { backgroundColor: '#afafaf' } 
        });
    
    }
    });
    

    hope this helps really it is very interactive.

提交回复
热议问题