Bootstrap Table table has been unable to load data

Source: Internet
Author: User

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

Here is a small problem: theBootstrap table table has been unable to 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 data, it's all right, but it's a mistake.

Workaround:

  converts the JSON data that is put back to object .

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


});

If you set the returned 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 returned response information Content-type to Text/html;charset=utf-8, the MSG returned is the JSON string.
Then you need to json.stringify (string) into the object and then load it.

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

Note: The solution to this article is only for my problem solved, please test your own.

Bootstrap Table table has been unable to load data

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.