How to display a loading image until a gridview is fully loaded without Ajax Toolkit?

前端 未结 6 709
一个人的身影
一个人的身影 2021-01-03 06:10

QUESTION

Can anyone suggest how a loading image can be displayed until a gridview is fully loaded?

This gridview is to be rendered on page

6条回答
  •  半阙折子戏
    2021-01-03 06:35

    You should load grid in another page and call that page in a div on parent page and display required loading image while loading div as per below code:

      $(document).ready(function()
       {
     $("#loader").show();
     $.ajax({
        type: "GET",
        url: "LoadGrid.aspx",
        data: "{}",
        contentType: "application/json",
        dataType: "json",   
        success: function(data) {
            $("#loader").hide();
           $(#dvgrid).html(data);
        },
        // it's good to have an error fallback
        error: function(jqhxr, stat, err) {
           $("#loader").hide();
     $(#dvgrid).html('');
           $("#error").show();
        }
      });
    });
    

    In LoadGrid.aspx you should load grid by normal C# code. and simply your parent page will call the LoadGrid.aspx and rendered html will display in parent div with loading image...

提交回复
热议问题