How to show processing animation / spinner during ajax request?

前端 未结 7 1685
礼貌的吻别
礼貌的吻别 2020-12-23 23:55

I want a basic spinner or processing animation while my AJAX POST is processing. I\'m using JQuery and Python. I looked at the documentation but can\'t figure out exactly

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-24 00:34

    I wrote a blog post about how to do this on a generic document level.

    // prepare the form when the DOM is ready 
    $(document).ready(function() { 
    
      // Setup the ajax indicator
      $('body').append('

    '); $('#ajaxBusy').css({ display:"none", margin:"0px", paddingLeft:"0px", paddingRight:"0px", paddingTop:"0px", paddingBottom:"0px", position:"absolute", right:"3px", top:"3px", width:"auto" }); }); // Ajax activity indicator bound to ajax start/stop document events $(document).ajaxStart(function(){ $('#ajaxBusy').show(); }).ajaxStop(function(){ $('#ajaxBusy').hide(); });

提交回复
热议问题