How to call .ajaxStart() on specific ajax calls

前端 未结 10 835
孤独总比滥情好
孤独总比滥情好 2020-11-28 03:47

I have some ajax calls on the document of a site that display or hide a progress bar depending on the ajax status

  $(document).ajaxStart(function(){ 
              


        
10条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 04:24

    If you put this in your function that handles an ajax action it'll only bind itself when appropriate:

    $('#yourDiv')
        .ajaxStart(function(){
            $("ResultsDiv").hide();
            $(this).show();
        })
        .ajaxStop(function(){
            $(this).hide();
            $(this).unbind("ajaxStart");
        });
    

提交回复
热议问题