处理Bootstrap表中URI的错误

本文关键字:错误 URI 表中 Bootstrap 处理 | 更新日期: 2023-09-27 18:06:40

我使用Bootstrap表来表示集合。表格由url: MyAjaxAddress填充,它在HTML代码中声明。但有时当服务器端出现问题时,我想要显示信息消息。

<table data-url="MyAjaxAddress" ... >
    <thead>

我的问题是:如何从表属性返回HTTP 500时MyAjaxAddress触发javascript函数

处理Bootstrap表中URI的错误

我找到解决办法了

$('#bootstrapTableId').bootstrapTable({
    onLoadError: function (status) {
        MyJsFunction();
    }
});

我希望我是对的。

data-url 希望 json数组

因此,您可以首先通过Ajax获取Json,检查http状态,然后将其分配给表。

var json = {};
$.ajax({url: "MyAjaxAddress",
  success: function(data){
    json = data;
  },
  error: function(xhr){
    alert("An error occured: " + xhr.status + " " + xhr.statusText);
  }
});
$('table').data("url", json);