English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Quick Solution to Bootstrap Table Not Loading Data

bootstrap-table is a powerful table plugin based on Bootstrap style, official website:http://bootstrap-table.wenzhixin.net.cn/zh-cn/

  Here is a small problem encountered: The Bootstrap Table does not load data.

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

  I use the json data returned from the remote address as the data, which is completely fine, but it keeps on giving errors.

  Solution:

  Convert the returned json data into an object.

$("#button").click(function(){}
    var name=$("input[name='name']").val();
    $.ajax({
        type: "POST",
        url:"../Query/FindMoonByName?name="+name,
         success: function(msg){
           //Here msg is a JSON object, not a JSON string.
           $('#table').bootstrapTable('load',msg); 
         } 
     }); 
  });

  If you set the returned response information Content-Type is application/json;charset=UTF-8, the returned msg is a JSON object.
  Then you can load it directly.

  If you set the returned response information Content-Type is text/html;charset=UTF-8, the returned msg is a JSON string.

  Then you need to convert the string to an object with JSON.stringify(string) before loading.

  Test:

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

The above-mentioned is the quick solution to the problem that Bootstrap Table data cannot be loaded as introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave a message, and the editor will reply to everyone in time. At the same time, I also thank everyone for their support of the Yelling Tutorial website!

Statement: The content of this article is from the Internet, and the copyright belongs to the original author. The content is contributed and uploaded by Internet users spontaneously. This website does not own the copyright, has not been manually edited, and does not assume relevant legal liabilities. If you find any content suspected of copyright infringement, please send an email to: notice#oldtoolbag.com (When sending an email, please replace # with @ to report abuse, and provide relevant evidence. Once verified, this site will immediately delete the content suspected of infringement.)

You May Also Like