想要显示ajax加载gif

no_*_*dom 1 php ajax jquery

我正在使用DataTables.我的所有代码都运行正常.现在我想把ajax加载gif.任何人都可以帮我把ajax加载器gif?这是我的代码.谢谢

         <script type="text/javascript" charset="utf-8">
        $(document).ready(function() {
        $("#dvloader").show();
            oTable = $('#example').dataTable({
                "bJQueryUI": true,
                "sPaginationType": "full_numbers"                   
            });
        } );                 
         (document).ready(function() {
            $("#btnround").click(function(){
                $.ajax({
                  url: "ajax_request.php",
                  cache: false,
                  async: true,
                  data: "shape=ROUND",
                  success: function(html){
                    $(".demo_jui").html(html);
                }
                });
            });
    });
           </script>
Run Code Online (Sandbox Code Playgroud)

pcr*_*aft 6

使用

ajaxStart()

ajaxComplete()

用于显示和隐藏加载gif的函数.

$("#loading").ajaxStart(function(){
   $(this).show();
 });

$("#loading").ajaxComplete(function(){
   $(this).hide();
 });
Run Code Online (Sandbox Code Playgroud)

而div或元素与id

装载

有加载GIF.

您的最终代码应如下所示:

<script type="text/javascript" charset="utf-8">
    $(document).ready(function() {
        $("#dvloader").show();
        oTable = $('#example').dataTable({
            "bJQueryUI": true,
            "sPaginationType": "full_numbers"
        });
    });
    (document).ready(function() {
        $("#btnround").click(function() {
            $.ajax({
                url: "ajax_request.php",
                cache: false,
                async: true,
                data: "shape=ROUND",
                success: function(html) {
                    $(".demo_jui").html(html);
                }
            });
        });
        $("#loading").ajaxStart(function(){
          $(this).show();
        });

        $("#loading").ajaxComplete(function(){
          $(this).hide();
        });        

    });
</script>
Run Code Online (Sandbox Code Playgroud)