【问题标题】:Handle error from URI in Bootstrap table处理来自 Bootstrap 表中 URI 的错误
【发布时间】:2015-10-28 05:44:00
【问题描述】:

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

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

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

【问题讨论】:

    标签: javascript c# html twitter-bootstrap model-view-controller


    【解决方案1】:

    我找到了解决办法

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

    【讨论】:

      【解决方案2】:

      我希望我是对的。

      data-url 想要一个 Json-Array

      所以您可以先通过 Ajax 获取您的 Json,检查 http-state,然后将其分配给表。

      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);

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-11-04
        • 2010-11-11
        • 2017-05-16
        • 1970-01-01
        • 1970-01-01
        • 2016-06-08
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多