javascript - 引导表刷新

标签 javascript ajax bootstrap-table

我正在使用 bootstrap 表通过 mongoid 查询来显示来自 MongoDB 的数据。我想每隔 5 分钟刷新一次表。我已阅读文档,但作为 Javascript 新手,我不确定如何实现此目的 - 是使用 Ajax 调用还是仅使用 setTimeout() 函数等。

这是我的表代码:

<table id="table" data-show-refresh="true" data-row-style="rowStyle" data-toggle="table" data-url="http://maccdx160121:4567/api/v1/currentsat*">
    <thead>
        <tr>

           <th data-field="initials">Initials</th>
            <th data-cell-style="cellStyle" data-field="sector">Sector</th>
            <th data-field="cjs">CJS</th>


        </tr>
    </thead>
 </table>

这是我的 Mongoid 查询,如果有帮助的话:

get '/currentsat*' do

    #SatTransaction.where( current: true, :initials.ne => nil, :position.in => ["RDR", "SPVR", "OJI"] ).to_json
    SatTransaction.where( current: true, :shift_duration.ne => 0, ).and(SatTransaction.or({:position.in => ["SPVR", "RDR", "OJI"]},{sector: "BREAK"}).selector).to_json


    end



end

before do
  cache_control :no_cache
end

def with_captured_stdout
  old_stdout = $stdout
  $stdout = StringIO.new('', 'w')
  yield
  $stdout.string
ensure
  $stdout = old_stdout
end

感谢您的帮助!!

最佳答案

我认为您删除了该表并重新创建了它:

setInterval(function(){
    $('#table').remove();
    $('#Table_Parent').append(Table_Html);
}, 5000);

关于javascript - 引导表刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42100051/

相关文章:

javascript - 在 AngularJS 中使用元数据动态插入指令?

javascript - 成功的 AJAX 请求破坏了 jQuery 函数

javascript - AngularJS 中 Controller 对象的生命周期

jquery - Bootstrap-Table:如何隐藏列而不从 DOM 中删除它?

twitter-bootstrap - Bootstrap 表中的多个数据字段

javascript - 如何在 Canvas 上填充图案并沿着形状弯曲?

javascript - 使用 Javascript 从日期中减去工作日

javascript - 避免在 updateOptions 调用中清理 Canvas

javascript - 如何在 Firefox 57.x 控制台中调查 reponseText/长文本?

javascript - 记住 Bootstrap 表中的页面大小