Bootstrap Table表格一直載入(load)不了資料的快速解決方案,bootstraptable

來源:互聯網
上載者:User

Bootstrap Table表格一直載入(load)不了資料的快速解決方案,bootstraptable

bootstrap-table是一個基於Bootstrap風格的強大的表格外掛程式神器,官網:http://bootstrap-table.wenzhixin.net.cn/zh-cn/

  這裡列出遇到的一個小問題:Bootstrap Table表格一直載入不了資料。

  $("#button").click(function(){    var name=$("input[name='name']").val();    $('#table').bootstrapTable('load',"../Query/FindMoonByName?name="+name);  });

  我使用訪問遠程地址返回的json資料作為資料,完全沒問題啊,但是就是出錯了。

  解決方案:

  將放回的json資料轉換為object對象。

$("#button").click(function(){    var name=$("input[name='name']").val();    $.ajax({        type: "POST",        url:"../Query/FindMoonByName?name="+name,         success: function(msg){           //這裡的msg是json對象,不是json字串。           $('#table').bootstrapTable('load',msg);          }      });   });

  如果你設定返回的響應資訊Content-Type為application/json;charset=UTF-8,返回的msg就是json對象。
  這時你直接載入就可以。

  如果你設定返回的響應資訊Content-Type為text/html;charset=UTF-8,返回的msg就是json字串。

  那你需要JSON.stringify(字串)轉為對象再進行載入。

  測試:

  Bootstrap-table.js   version: 1.11.1
  Bootstrap.js         v3.3.0

以上所述是小編給大家介紹的Bootstrap Table表格一直載入(load)不了資料的快速解決方案,希望對大家有所協助,如果大家有任何疑問歡迎給我留言,小編會及時回複大家的,在此也非常感謝大家對幫客之家網站的支援!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.