来自ajax的Bootstrap表json [英] Bootstrap Table json from ajax

查看:80
本文介绍了来自ajax的Bootstrap表json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了ajax和bootstrap表的问题。
我有一个用这种方法调用的ajax JSON:

I have a problem with ajax and bootstrap table. I have an ajax JSON I call with this method:

$(document).ready(function(){

  $.ajax({
       url: 'php/process.php?method=fetchdata',
       dataType: 'json',
       success: function(data) {
           $('#clienti').bootstrapTable({
              data: data
           });
       },
       error: function(e) {
           console.log(e.responseText);
       }
    });
 });

我的JSON似乎正确,但表格没有显示任何记录。我做错了什么?

My JSON seems correctly but the table doesn't show any record. What am I doing wrong?

这里也是表格定义

<table data-toggle="table" class="display table table-bordered" id="clienti">
  <thead>
    <tr>
      <th>Nome</th>
      <th>Cognome</th>
      <th>Data Nascita</th>
      <th>Provincia</th>
      <th>Comune</th>
      <th>CAP</th>
      <th>Indirizzo</th>
      <th>Fisso</th>
      <th>Cellulare</th>
      <th>Note</th>
    </tr>
  </thead>

</table>

这也是返回的json的一部分

This is also a part of the json that is returned

[{"Nome":"","Cognome":"","DataN":"0000-00-00","Provincia":"","Comune":"","CAP":"","Indirizzo":"","Fisso":"","Mobile":"","Note":""},{"Nome":"Federico","Cognome":"Lupieri","DataN":"2015-09-16","Provincia":"","Comune":"","CAP":"34170","Indirizzo":"Via Ascoli 1","Fisso":"00112233445566","Mobile":"00112233445566","Note":"Vediamo se funziona questo"},


推荐答案

检查这个小提琴

您必须在每个中指定数据字段 您还必须删除 data-toggle =table

data-toggle =table as 文档激活引导选项卡le没有编写JavaScript。在普通表格上设置data-toggle =table。

如果您不想使用javascript,请执行以下表格,如下所示

in your case if you don't want to use javascript just do your table as below

<table data-toggle="table" class="display table table-bordered" data-url="php/process.php?method=fetchdata">
    <thead>
        <tr>
            <th data-field="Nome">Nome</th>
            <th data-field="Cognome">Cognome</th>
            <th data-field="DataN">Data Nascita</th>
            <th data-field="Provincia">Provincia</th>
            <th data-field="Comune">Comune</th>
            <th data-field="CAP">CAP</th>
            <th data-field="Indirizzo">Indirizzo</th>
            <th data-field="Fisso">Fisso</th>
            <th data-field="Mobile">Cellulare</th>
            <th data-field="Note">Note</th>
        </tr>
    </thead>
</table>

这篇关于来自ajax的Bootstrap表json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆