drruhc4944 2016-04-28 04:02
浏览 84

ajax加载gif没有删除成功

i currently have a table that loads a bunch of results via an ajax request you can see the code below. however when i try to add a loading gif i am only seeing the loading gif on the page it doesn't remove itself after the ajax request was suscessfull

i can see the page fire the ajax request and it return the data

i am chasing the loading bar to show while the ajax is processing then hide when its loaded

this is the html code

<div class='content'>
    <div class='panel panel-flat' id='records_loading'>
        <table class='table table-togglable table-hover table-striped' data-limit-navigation='5' data-page-size='20'>
            <thead class='bg-teal'>
                <tr>
                    <th data-toggle='true' data-type='numeric'>SMS ID</th>
                    <th data-hide='phone'>Time Stamp</th>
                    <th data-hide='phone,tablet'>Mobile Number</th>
                    <th data-hide='phone,tablet'>Message</th>
                    <th data-hide='phone,tablet'>Message Status</th>
                </tr>
            </thead>
            <tbody  id='records_table'>
            </tbody>
        </table>
    </div>
<ul class='pagination pagination-separated hide-if-no-paging'></ul>
</div>

this is the ajax code

<script>
function showResult(str) {  
    $.ajax({
        url: '/getjson.php?search='+str, 
        type: 'POST',    
        dataType:'json',
        beforeSend:function(response)
       {
        $('#records_loading').html('<img src="assets/content/login.gif">');
       },
        success: function (response) 
        {
          var trHTML = '';
          $.each(response, function (key,value) {
             trHTML += 
                '<tr><td>' + value.ID + 
                '</td><td>' + value.Timestamp + 
                '</td><td>' + value.Number + 
                '</td><td>' + value.Message + 
                '</td><td>' + value.Status + 
                '</td></tr>';     
          });
            $('#records_table').html(trHTML);
            $('.table-togglable').trigger('footable_redraw');
        }
    }); 
}
showResult('');
</script>
  • 写回答

4条回答 默认 最新

  • dongshuiga2826 2016-04-28 04:07
    关注
        success: function (response) 
        {
           $('#records_loading').html('<table class='table table-togglable table-hover table-striped' data-limit-navigation='5' data-page-size='20'><thead class='bg-teal'>');
        }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)