【发布时间】:2017-06-25 07:11:08
【问题描述】:
我正在使用引导表显示来自我的 MongoDB 的数据,使用 mongoid 查询。我想每隔 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
感谢您的帮助!!
【问题讨论】:
标签: javascript ajax bootstrap-table