bootstrap表不显示数据

问题描述 投票:0回答:0

$('#Modal').modal('toggle'); var row_id = $('#id').val(); $.ajax ({ url: "test.php", data: { id : row_id }, method:"POST", //async: false, dataType:"json", success: function( result ) { var obj=result; var obj1=JSON.parse(obj); //table $('#table1').bootstrapTable('load', obj1); var $table = $('#table1'); $table.bootstrapTable({ search: true, pagination: true, buttonsClass: 'primary', showFooter: true, minimumCountColumns: 2, columns: [{ field: 'num', title: 'ID' }, { field: 'first', title: 'firstname' }, { field: 'second', title: 'second Name' }, { field: 'three', title: 'last name' }, { field: 'four', title: 'father name' }, { field: 'five', title: 'Gender' }, { field: 'six', title: 'class' }, { field: 'seven', title: 'total marks' }, { field: 'last', title: 'percentage' }], data: obj }); } });enter image description here

我遵循了此示例
Https://www.sourcecodesite.com/use-bootstrap-tables-display-data-mysql.html
。但是问题是我的数据没有显示。桌子在加载时为空 我将显示数据的PHP代码

<?php //require 'db.php'; $con = mysqli_connect("localhost","root","","test"); if(isset($_POST['id'])) { $sqltran = mysqli_query($con, "SELECT * FROM table WHERE id = '".$_POST['id']."'")or die(mysqli_error($con)); $arrVal = array(); $i=1; while ($rowList = mysqli_fetch_array($sqltran)) { $name = array( 'id' => $rowList['id'], 'first'=> $rowList['A'], 'second'=> $rowList['B'], 'three'=> $rowList['C'], 'four'=> $rowList['D'], 'five'=> $rowList['E'], 'six'=> $rowList['F'], 'seven'=> $rowList['G'], 'last'=> $rowList['H'] ); array_push($arrVal, $name); $i++; } echo json_encode($arrVal); mysqli_close($con); } ?>

trory这样编辑您的代码:

var $table = $('#table1'); $table .bootstrapTable('load', obj1); $table.bootstrapTable({ search: true, pagination: true, buttonsClass: 'primary', showFooter: true, minimumCountColumns: 2, columns: [{ field: 'num', title: 'ID' }, { field: 'first', title: 'firstname' }, { field: 'second', title: 'second Name' }, { field: 'three', title: 'last name' }, { field: 'four', title: 'father name' }, { field: 'five', title: 'Gender' }, { field: 'six', title: 'class' }, { field: 'seven', title: 'total marks' }, { field: 'last', title: 'percentage' }], data: obj }); } });
	
jquery mysql bootstrap-table
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.