我正在使用引导表来显示来自我的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调用那么专业。 ()函数(){ location.reload(); },60 * 1000); – user2843365