bootstrapTable 不刷新新创建的 json
bootstrapTable doesn't refresh with the newly created json
一切正常,直到我们将应用程序转移到新域。现在它根本不会用新生成的 json 刷新 table。
$('input[name^=\"tbl-\"]').on('change', function() {
let elem = $(this)
$.post(
'/analytics/admin/site/index',
{index: $(this).data('index'), value: $(this).val()}
)
.done(function(data){
let table = elem.next('.example').find('table')
table.eq(1).bootstrapTable('refresh')
})
})
执行刷新操作(刷新时窗体闪烁,控制台中也没有错误)。在 .done()
中尝试使用 console.log
并且请求成功。网络选项卡中也没有错误。
没有看到您的 table 的标记,很难知道您希望如何更新其中包含的数据。如果您希望它填充从 POST 返回的 data
值,我认为您需要设置数据选项:
.done(function(data){
let table = elem.next('.example').find('table')
table.eq(1).bootstrapTable({data: data})
table.eq(1).bootstrapTable('refresh')
})
参见:https://examples.bootstrap-table.com/#welcomes/from-data.html
如果您在 table 上使用 data-url
属性,您可能需要检查 URL 是否对您的新域仍然有效。
一切正常,直到我们将应用程序转移到新域。现在它根本不会用新生成的 json 刷新 table。
$('input[name^=\"tbl-\"]').on('change', function() {
let elem = $(this)
$.post(
'/analytics/admin/site/index',
{index: $(this).data('index'), value: $(this).val()}
)
.done(function(data){
let table = elem.next('.example').find('table')
table.eq(1).bootstrapTable('refresh')
})
})
执行刷新操作(刷新时窗体闪烁,控制台中也没有错误)。在 .done()
中尝试使用 console.log
并且请求成功。网络选项卡中也没有错误。
没有看到您的 table 的标记,很难知道您希望如何更新其中包含的数据。如果您希望它填充从 POST 返回的 data
值,我认为您需要设置数据选项:
.done(function(data){
let table = elem.next('.example').find('table')
table.eq(1).bootstrapTable({data: data})
table.eq(1).bootstrapTable('refresh')
})
参见:https://examples.bootstrap-table.com/#welcomes/from-data.html
如果您在 table 上使用 data-url
属性,您可能需要检查 URL 是否对您的新域仍然有效。