Bootstrap table table has been loaded (load) a quick solution to the data _javascript tips

Source: Internet
Author: User

Bootstrap-table is a powerful form-plug-in artifact based on the bootstrap style, official website: http://bootstrap-table.wenzhixin.net.cn/zh-cn/

Here's a small problem: the Bootstrap table 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 by accessing the remote address as data, but it's a mistake.

  Workaround:

Converts the returned JSON data to object.

$ ("#button"). Click (function () {
    var name=$ ("Input[name= ' name ')"). Val ();
    $.ajax ({
        type: POST),
        URL: ".. /query/findmoonbyname?name= "+name,
success:function (msg) {
///MSG Here is a JSON object, not a JSON string.        
$ (' #table '). Bootstraptable (' Load ', msg); 
} 
); 
});

If you set the return response information Content-type to Application/json;charset=utf-8, the returned MSG is the JSON object.
Then you can load it directly.

If you set the return response information Content-type to Text/html;charset=utf-8, the returned MSG is the JSON string.

Then you need to json.stringify (string) to object and then load.

Test:

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

The above is the small set to introduce the Bootstrap table table has been loaded (load) can not be a quick solution to the data, hope to be helpful to everyone, if you have any questions welcome to my message, small series will promptly reply to everyone, here also thank you for the cloud Habitat Community website support!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.